i have this table
Cream ---------- CHOCALATE GREEN TEST
want out put in select query 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 the others said, use COALESCE...
DECLARE @List VARCHAR(1000)
SELECT @List = COALESCE(@List + ', ', '') + Name
FROM Cream
SELECT @List
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With