Site Sponsored By: SQLDSC - SQL Server Desired State Configuration
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.
I need to add a column to a query that always returns one single record.select some_columns from table1where condition ='whatsoever'now, the column I have to add is specified by this relationsship:table2 on table1.link = table2.link and table2.whereclause ='whatsoever'this relationsship returns more records and my goal is now to convert that column -or one dimensional array- into string, with komma delimiters.value1value2..valueNbecomes the scalar (value1, value2, ... valueN) that can be added to my inicial Query.Anyone has a clue?Regards, Martin
select some_columns,stuff((select ',' + field from table2 where table1.link = link and whereclause ='whatsoever' for xml path('')),1,1,'')from table1 t1where condition ='whatsoever'
------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/
barnabeck
Posting Yak Master
236 Posts
Posted - 2012-05-02 : 11:38:57
I was too busy with other things all that time and just happen to get back on that matter...Great STUFF!!! (literally spoken)Works great and does exactly what I needed!Thank you Visakh16!Martin
visakh16
Very Important crosS Applying yaK Herder
52326 Posts
Posted - 2012-05-02 : 19:34:08
quote:Originally posted by barnabeck I was too busy with other things all that time and just happen to get back on that matter...Great STUFF!!! (literally spoken)Works great and does exactly what I needed!Thank you Visakh16!Martin
welcome ------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/