Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
jgrant
Yak Posting Veteran
69 Posts |
Posted - 2007-03-20 : 14:03:44
|
| Some guy posted that the syntax: delete top 1 from some_table works for deleting duplicates. I am pretty sure that doesnt work but I wanted to check just in case it did because it would be a really easy to delete duplicates.The Yak Village Idiot |
|
|
X002548
Not Just a Number
15586 Posts |
|
|
jgrant
Yak Posting Veteran
69 Posts |
Posted - 2007-03-20 : 14:51:26
|
| I am using sql 2000. I want to add error checking for duplicates at the end of a stored procedure. So, I was thinking that I should insert the data into a temporary table if @@rowcount distinct column > 1 then first and then select distinct into the actual table where I am storing the data. If it returns @@rowcount = 0 then just insert directly into the table. Is this a good idea or is there a better idea for error checking and deleting duplicates?The Yak Village Idiot |
 |
|
|
Jeff Moden
Aged Yak Warrior
652 Posts |
Posted - 2007-03-20 : 23:19:58
|
| Create the staging table (temporary table) with a Primary Key that uses the IGNORE DUPES option to keep dupes out of the staging table. Then, do a cross check against the final target table using an outer join and only insert the rows that have no match. You do not need SELECT DISTINCT.--Jeff Moden |
 |
|
|
|
|
|