July 5, 2007 at 2:52 am
July 5, 2007 at 3:04 am
Hi
declare @var varchar(100)
set @var = ''
select @var = @var + cast(col1 as varchar(3)) + ',' from table
-- to remove the trailing comma
set @var = left(@var ,(len(@var )-1))
select @var
"Keep Trying"
July 5, 2007 at 4:48 am
July 9, 2007 at 5:35 am
July 12, 2007 at 6:30 am
SQL 2005 - XML way
select col1, stuff( ( select ','+ col2
from tab1 t1
where t2.col1 = t1.col1
for xml path('')
),1,1,'')
from tab1 t2
group by col1
order by col1
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply