Robert L. Stewart
rl_stewart at highstream.net
Mon Jan 15 13:22:02 CST 2007
John, take a look at cursors. They operate like recordsets do in Access. If you know how to do it in Access with a recordset, you can do the same with a cursor in SQL Server. Robert At 12:00 PM 1/15/2007, you wrote: >Date: Sun, 14 Jan 2007 22:49:28 -0500 >From: "JWColby" <jwcolby at colbyconsulting.com> >Subject: [dba-SQLServer] deduplication >To: "'Access Developers discussion and problem solving'" > <accessd at databaseadvisors.com>, <dba-sqlserver at databaseadvisors.com> >Message-ID: <007801c73858$28f96920$657aa8c0 at m6805> >Content-Type: text/plain; charset="us-ascii" > >Is there a SQL syntax or method for identifying duplicate records based on >and automatically removing (or marking) the second and subsequent instances >of that record. > >I am working with a database where there may be several records for the same >person. Each record will have slightly different data in the record. I >need to find all the records for a given person, remove or somehow flag the >"duplicate" records, and eventually "merge" the duplicate records together. > > >I know how to use groupby and count to find the dupes but I don't really >know how to then merge fields F through M from records 2,3 and 4 back into >fields F through M in record 1. This is going to be an ongoing project so I >need to learn the methodology to get it done. I can do it with recordsets >and code, but not with SQL, and given the large potential numbers of records >SQL would be my first choice. > >John W. Colby >Colby Consulting >www.ColbyConsulting.com