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
 Combine data from multiple rows

Author  Topic 

thakur80
Starting Member

3 Posts

Posted - 2015-02-05 : 16:56:45
Hello! I am running a query to pull data from 2 tables. However multiple data elements could be attached to one unique ID which when I run the query it repeats causing the entire data set to give inaccurate numbers. Can someone help me achieve this:

xxx.001 A3264
xxx.001 A3685
xxx.002 A3261
xxx.002 A3685

I would like my results to look like this:

xxx.001 A3264 & A3685
xxx.002 A3261 & A3685

bitsmed
Aged Yak Warrior

545 Posts

Posted - 2015-02-05 : 17:21:55
[url]http://www.dbsimplified.com/2011/06/groupconcat-in-microsoft-sql-server.html[/url]
Go to Top of Page

thakur80
Starting Member

3 Posts

Posted - 2015-02-05 : 18:43:27
Thanks for the link but I am now stuck with a data loop of upto 8000 characters (as specified in the example). I am now able to get the rows to combine but the data keeps going into loop and keep repeating itself.

xxx.001 A3264,A3685,A3264,A3685A3264,A3685A3264,A3685A3264,A3685A3264,A3685A3264,A3685A3264,A3685A3264,A3685A3264,A3685A3264,A3685A3264,A3685A3264,A3685......and so on up until 8000 characters
xxx.002 A3261,A3685,A3261,A3685A3261,A3685A3261,A3685A3261,A3685A3261,A3685A3261,A3685A3261,A3685A3261,A3685A3261,A3685A3261,A3685A3261,A3685A3261,A3685......and so on up until 8000 characters
Go to Top of Page
   

- Advertisement -