[dba-SQLServer] merging records

Arthur Fuller fuller.artful at gmail.com
Tue Nov 13 07:17:46 CST 2007


Given an unknown number of duplicate person records (for different polls), I
can't think offhand of a set-based way to do it (although perhaps a creative
use of COALESCE() might work). I think that the recordset approach may be
your best option. Even that approach might have problems, however. I may
have filled in one poll as Arthur Fuller and another as Arthur B. Fuller.

A.

On 11/13/07, jwcolby <jwcolby at colbyconsulting.com> wrote:
>
> I have tables of information about people.  The tables represent polls
> that
> people have taken, so if a person takes a poll about brands of cigarettes
> smoked, the table would have a record about that person for that poll.  If
> that same person took a poll about software used, the table would have a
> NEW
> record with information about the same person, but about the software that
> person used.  And so forth and so on.  Now I need to "roll up" all of the
> information about a person into a single record so that one record
> contains
> all of the information about that person contained in all of the records
> about that person in the table.
>
> Is this possible directly in SQL?  Do I need to write code to iterate
> through the table finding each person and all the records for that person,
> and then consolidating the information from the second and subsequent
> records into the first record found?
>
> John W. Colby
> Colby Consulting
> www.ColbyConsulting.com
>



More information about the dba-SQLServer mailing list