I have this table
Cream ---------- CHOCALATE GREEN TEST
I want to request a choice like this
CHOCALATE, GREEN, TEST
With sysobjects, this worked:
DECLARE @List varchar(2000) SELECT @List = COALESCE(@List + ',', '') + Cast(name As varchar(50)) FROM sys.sysobjects SELECT @List As 'List'
I found a useful resource here when I needed to do this, but as others have said, use COALESCE ...
DECLARE @List VARCHAR(1000) SELECT @List = COALESCE(@List + ', ', '') + Name FROM Cream SELECT @List
coalesce
- , , .
.
http://msdn.microsoft.com/en-us/library/ms165055.aspx
Your query will look like this: "SELECT dbo.Concatenate (Field) FROM Cream"
You will be returned what you expect from "a, b, c, d ...", etc.