This is a slightly tricky quey. Don get confused, just replace the column & table names and execute it.
DECLARE @str VARCHAR(5000)
SELECT
@str = COALESCE(@str+',','')+
(SELECT CAST(ColumnA as varchar(50)) FROM TableA A WHERE A.ColumnA = B.ColumnA) FROM
TableA B
Select @Str
Note: The tables used are the same tables with different aliases. And the whole query should be executed in a single batch(ie., no "Go" in between the these set of statements)
Subscribe to:
Post Comments (Atom)
1 comment:
You write very well.
Post a Comment