[dba-SQLServer] Delete all records of a particular type from atable except for one copy.

Susan Harkins ssharkins at setel.com
Sun Jul 8 20:32:39 CDT 2007


Why would you need an AutoNumber field? 

Find the records that match MyCode -- grab the top record and change its
MyCode value -- run the first query as a delete, reset  the top record's
MyCode value. 

Or, count the records and grab the count -1 in your delete -- can you do
that? 

Susan H. 

It may sound funny but I do not care which record is the record left. I was
hoping that another step of adding an 'autoNumber' field was not necessary
but maybe it is...





More information about the dba-SQLServer mailing list