SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Keep unique record and merge the contents
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

allan8964
Posting Yak Master

247 Posts

Posted - 11/26/2012 :  17:34:09  Show Profile  Reply with Quote
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
Flowing Fount of Yak Knowledge

2143 Posts

Posted - 11/27/2012 :  06:36:19  Show Profile  Reply with Quote
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

247 Posts

Posted - 11/27/2012 :  11:44:39  Show Profile  Reply with Quote
[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
Flowing Fount of Yak Knowledge

USA
7174 Posts

Posted - 11/27/2012 :  14:15:05  Show Profile  Reply with Quote
Merge Col1 based on Id????

Please give examples and expected output.
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.06 seconds. Powered By: Snitz Forums 2000