dbTalk Databases Forums  

Help with combining data from multiple rows into one column in a view

comp.databases.ms-sqlserver comp.databases.ms-sqlserver


Discuss Help with combining data from multiple rows into one column in a view in the comp.databases.ms-sqlserver forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
gaholmes@comcast.net
 
Posts: n/a

Default Help with combining data from multiple rows into one column in a view - 07-19-2007 , 12:37 PM






Hi, I am stumped and was hoping someone could help me out. Any help is
appreciated.


I have a view that looks sort of like this (but with a lot more
entries of course)


UniqueIdentifyier Column1 Column2
1 9999 100
2 9999 200
3 9999 300


What I want to do is to add a column to the view that will contain a
list of the values from column 2 where column 1 is the same.

UniqueIdentifyier Column1 Column2 Column3
1 9999 100 100, 200, 300
2 9999 200 100, 200, 300
3 9999 300 100, 200, 300


Reply With Quote
  #2  
Old   
Erland Sommarskog
 
Posts: n/a

Default Re: Help with combining data from multiple rows into one column in a view - 07-19-2007 , 03:59 PM






(gaholmes (AT) comcast (DOT) net) writes:
Quote:
Hi, I am stumped and was hoping someone could help me out. Any help is
appreciated.


I have a view that looks sort of like this (but with a lot more
entries of course)


UniqueIdentifyier Column1 Column2
1 9999 100
2 9999 200
3 9999 300


What I want to do is to add a column to the view that will contain a
list of the values from column 2 where column 1 is the same.

UniqueIdentifyier Column1 Column2 Column3
1 9999 100 100, 200, 300
2 9999 200 100, 200, 300
3 9999 300 100, 200, 300
This may not be doable in a view, particularly if you are on SQL 2000.

SQL Server MVP Anith Sen has a collection of methods to attack this
problem at http://www.projectdmx.com/tsql/rowconcatenate.aspx.


--
Erland Sommarskog, SQL Server MVP, esquel (AT) sommarskog (DOT) se

Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pro...ads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinf...ons/books.mspx


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.