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
 General SQL Server Forums
 Script Library
 cross tab char/varchar (a solution)

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2002-01-17 : 20:50:27
Louis writes "Thought I share this snippet. You can "concatenate" over rows, using the update statement. The result rows are: ROW1 [C,], ROW2 [B,C], ROW3 [A,B,C].

create table #me (text varchar(1),notes varchar(100))
insert into #me
select text='A',notes=' '
UNION
select text='B',notes=' '
UNION
select text='C',notes=' '

declare @text varchar(1000)
select @text = null
update #me
set @text = notes = text +','+ isnull(@text,'')

select * from #me"
   

- Advertisement -