Site Sponsored By: SQLDSC - SQL Server Desired State Configuration
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.
Hello,This may be a strange request, but I am going to ask about it anyways.Say for example if I have a table named TEST and in the table there is a column named NUMBERS, such that it is like this:NUMBERS1234How could I use a select statement in a way that a comma would seperate every return value, such that if I go 'Select NUMBERS from TEST' I would get:1,2,3,4Instead of:1234Any ideas?Thanks
madhivanan
Premature Yak Congratulator
22864 Posts
Posted - 2005-01-12 : 07:53:23
Try this
Declare @s nvarchar(300)set @s=''select @s=@s+','+convert(nvarchar(20),numbers) from testselect substring(@s,2,len(@s))
Madhivanan
nr
SQLTeam MVY
12543 Posts
Posted - 2005-01-12 : 10:45:57
orDeclare @s nvarchar(300)select @s = coalesce(@s + ',', '') + convert(nvarchar(20),numbers) from testselect @s==========================================Cursors are useful if you don't know sql.DTS can be used in a similar way.Beer is not cold and it isn't fizzy.