August 15, 2011 at 11:06 am
COLUMNA COLUMNB
123 JSOSJD
433 SDFOJE
123 DODOD
123 399SD
"JSOSJD,DODOD,399SD" where columnA=123
August 15, 2011 at 11:18 am
Try the stuff function:
Select STUFF(
(SELECT ',' + a.columnA AS [text()]
from yourtable a
for xml PATH('')),1,1,'' )
Where columnA=123
Jason...AKA CirqueDeSQLeil
_______________________________________________
I have given a name to my pain...MCM SQL Server, MVP
SQL RNNR
Posting Performance Based Questions - Gail Shaw[/url]
Learn Extended Events
August 15, 2011 at 11:48 am
Thanks. That gave me all rows in one so I changed the where clause and now it is accurate.
Select STUFF(
(SELECT ',' + a.columnA AS [text()]
from yourtable a Where columnA=123
for xml PATH('')),1,1,'' )
--Where columnA=123
--------------------------------------------------------------------------------
August 15, 2011 at 11:50 am
Glad it is working.
Jason...AKA CirqueDeSQLeil
_______________________________________________
I have given a name to my pain...MCM SQL Server, MVP
SQL RNNR
Posting Performance Based Questions - Gail Shaw[/url]
Learn Extended Events
August 29, 2011 at 6:55 am
Very nice! I will definitely find the STUFF fuction useful. Learning more and more each day thanks to you all! 🙂
September 7, 2011 at 6:37 pm
Tee Time (8/29/2011)
Very nice! I will definitely find the STUFF fuction useful. Learning more and more each day thanks to you all! 🙂
You do realize that all the STUFF function did was eliminate a leading comma, right? And that the FOR XML PATH did the rest, right? 😉
--Jeff Moden
Change is inevitable... Change for the better is not.
Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply