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
 General SQL Server Forums
 New to SQL Server Programming
 CSV in sqlserver procedure

Author  Topic 

Shilpa22
Starting Member

37 Posts

Posted - 2010-05-21 : 12:55:06
Hello All,
I need to pass list of values to a select statemnt(IN query)
I am generating CSV values as below
CREATE TABLE #temp1 (
QueueName varchar(500)
)
INSERT INTO #temp1
select Queue_ID from dws..dws_queue where performance_group_id =4

declare @tmp varchar(500)
declare @csv varchar(500)

SET @tmp = ''
select @tmp = @tmp + QueueName + ', ' from #temp1

set @csv = (select SUBSTRING(@tmp, 0, LEN(@tmp)))
print @csv
drop table #temp1

By this I am getting the values as 'aa,bb,cc'. returning value is varchar.
But i want the values as ('aa','bb','cc') to pass them in IN(list).

Please help me out
Thanks,
Silpa

Thanks in Advance
Shilpa

pk_bohra
Master Smack Fu Yak Hacker

1182 Posts

Posted - 2010-05-21 : 13:22:05
Have a look at below link. It will be of help to you.

http://www.sommarskog.se/arrays-in-sql-2005.html
Go to Top of Page
   

- Advertisement -