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.
Author |
Topic |
pl0689
Starting Member
3 Posts |
Posted - 2009-01-15 : 11:12:51
|
I am trying to figure out a way to pass a string array ie.(1,2,3,4,5) into a stored procedure parameter ie (@list)It would work as follows:procedure_call '1,2,3,4'CREATE PROCEDURE procedure_call @list varchar(255)AS SELECT * FROM mytable WHERE id IN(CAST(@list AS int))GOI continuously get "Error converting data type varchar to int". Has anyone ever been successful in doing this through a stored procedure. |
|
dinakar
Master Smack Fu Yak Hacker
2507 Posts |
Posted - 2009-01-15 : 11:16:50
|
yes...a lot... either search on these forums or I have an article on my blog about similar question.Dinakar Nethi************************Life is short. Enjoy it.************************http://weblogs.sqlteam.com/dinakar/ |
|
|
sodeep
Master Smack Fu Yak Hacker
7174 Posts |
Posted - 2009-01-15 : 11:22:51
|
http://vyaskn.tripod.com/passing_arrays_to_stored_procedures.htm |
|
|
pl0689
Starting Member
3 Posts |
|
sodeep
Master Smack Fu Yak Hacker
7174 Posts |
|
bklr
Master Smack Fu Yak Hacker
1693 Posts |
Posted - 2009-01-15 : 23:14:06
|
declare @list varchar(32)select @list = '1,5,7'SELECT * FROM urtableWHERE ','+@list+',' LIKE '%,'+CAST(id AS VARCHAR(256))+',%' |
|
|
|
|
|
|
|