- Feb 13, 2003
- 26,252
- 403
- 126
I am trying to figure out why inserting records into a table I'm working with is putting them in different order each time I insert them.
What's happening is a script runs that truncates this table (among others). Then another script does an insert into this and other tables, from a Staging database. If I run these scripts, say, twice, then a SELECT * of the table in question is showing the records in different order after each run. A SELECT * of the Staging table shows no change at all to it. I'm using Beyond Compare for comparison purposes, by the way.
The weird thing is, is that this different ordering is not happening on another table. Same procedure: truncate table, then insert into it from Staging. The only difference I saw was that the "INSERT INTO TableGood (columns) SELECT columns FROM Staging.TableGood" actually explicitly listed each column in the INSERT and SELECT clauses. The table that was showing different record ordering just had "INSERT INTO TableBad SELECT * FROM Staging.TableBad". Naturally I added columns to the TableBad INSERT/SELECT but that did not resolve the issue. I also changed the TRUNCATE to a DELETE FROM and that also did not resolve the issue.
Any ideas? I'm kinda stumped here, and need to figure this out as it's causing an issue in something else that's a high priority. Thanks much guys.
What's happening is a script runs that truncates this table (among others). Then another script does an insert into this and other tables, from a Staging database. If I run these scripts, say, twice, then a SELECT * of the table in question is showing the records in different order after each run. A SELECT * of the Staging table shows no change at all to it. I'm using Beyond Compare for comparison purposes, by the way.
The weird thing is, is that this different ordering is not happening on another table. Same procedure: truncate table, then insert into it from Staging. The only difference I saw was that the "INSERT INTO TableGood (columns) SELECT columns FROM Staging.TableGood" actually explicitly listed each column in the INSERT and SELECT clauses. The table that was showing different record ordering just had "INSERT INTO TableBad SELECT * FROM Staging.TableBad". Naturally I added columns to the TableBad INSERT/SELECT but that did not resolve the issue. I also changed the TRUNCATE to a DELETE FROM and that also did not resolve the issue.
Any ideas? I'm kinda stumped here, and need to figure this out as it's causing an issue in something else that's a high priority. Thanks much guys.