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
 SQL Server 2005 Forums
 Transact-SQL (2005)
 How do i assign a CSV value to a variable

Author  Topic 

mary_itohan
Posting Yak Master

191 Posts

Posted - 2008-09-13 : 00:37:54
Hello Guys,

I have a table with values as thus

Column name: recipients

Values are thus

recipients
2525425425
4567474764
5699401430
2272923300
3956035899
2009932542


I have a stored procedure and want to get this back.

quote:
declare @s varchar(8000)
SELECT @s = recipient FROM history

print @s


I want print statement to give me this values back

print @s = '2525425425,4567474764,5699401430,2272923300,3956035899,2009932542'

Any ideas ?

thanks a lot












_____________________


Yes O !

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2008-09-13 : 01:41:28
[code]
select @s = isnull(@s + ',', '') + receipient
from history
[/code]


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

raky
Aged Yak Warrior

767 Posts

Posted - 2008-09-13 : 03:18:02
quote:
Originally posted by khtan


select @s = isnull(@s + ',') + receipients
from history



KH
[spoiler]Time is always against us[/spoiler]





I think you had forgotten to give another argument for Isnull Function

select @s = isnull(@s + ',','') + recipients
from history

Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2008-09-13 : 03:19:31
Oops


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page
   

- Advertisement -