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
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Convert Col Rows to String Value

Author  Topic 

ismailc
Constraint Violating Yak Guru

290 Posts

Posted - 2011-01-05 : 16:01:30
Good day, i need help.

I return the following results, the results differs & therefore cant use a case:
Col1 Result
1
2
3

I would like return the value in string format: ('1','2','3')

Any ideas, Refards

ismailc
Constraint Violating Yak Guru

290 Posts

Posted - 2011-01-07 : 02:17:57
Hi, I got help & fixed my problem

select stuff((select ','+ convert(varchar(6),col1)as [data()]
from (select '001' as col1 union all select '002' as col1) v1
for xml path('')),1,1,'') As concatenated_string
Go to Top of Page
   

- Advertisement -