Jim Lawrence
accessd at shaw.ca
Sun Jul 8 21:04:33 CDT 2007
Hi Susan: I am not sure what you mean? I was just noting that the simplest way to differentiate records is to have a unique field and an autoNumber field would do... How do you build a piece of SQL code that will use the Count aggregate function to delete records? Please send an example. TIA Jim -----Original Message----- From: dba-sqlserver-bounces at databaseadvisors.com [mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf Of Susan Harkins Sent: Sunday, July 08, 2007 6:33 PM To: dba-sqlserver at databaseadvisors.com Subject: Re: [dba-SQLServer] Delete all records of a particular type fromatable except for one copy. 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... _______________________________________________ dba-SQLServer mailing list dba-SQLServer at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-sqlserver http://www.databaseadvisors.com