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.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Keep unique record and merge the contents

Author  Topic 

allan8964
Posting Yak Master

249 Posts

Posted - 2012-11-26 : 17:34:09
Hi there,

On Nov. 20 I submitted a question, see http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=180820 and sodeep gives perfect anwer. But now the situation is little bit different:
when the same combinationed recored found, here is the first part of the codes:

Select CodeId,TypeId,ModelId,Count(*),Col1, Col2, ........
into #temp
from Table
Group by CodeId,TypeId,ModelId
Having Count(*) > 1

Now I need merge col1 from duplicated records together. For example,
Id | Col1 | Col2 ...
11 | ABC | ...
13 | CBX | ...

after the merge, the save back record for Col1 should look like ABC,CBX and Col2 and the rest columns should remain intact.
How can I do this? Thanks in advance.

DonAtWork
Master Smack Fu Yak Hacker

2167 Posts

Posted - 2012-11-27 : 06:36:19
If you are saying you want to turn column 1 into a comma separated value, you should rethink your schema.
http://en.wikipedia.org/wiki/First_normal_form








How to ask: http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx

Go to Top of Page

allan8964
Posting Yak Master

249 Posts

Posted - 2012-11-27 : 11:44:39
[quote]Originally posted by DonAtWork

If you are saying you want to turn column 1 into a comma separated value, you should rethink your schema.
http://en.wikipedia.org/wiki/First_normal_form


Thanks for the reply but I don't think you understand my question.





Go to Top of Page

sodeep
Master Smack Fu Yak Hacker

7174 Posts

Posted - 2012-11-27 : 14:15:05
Merge Col1 based on Id????

Please give examples and expected output.
Go to Top of Page
   

- Advertisement -