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 |
nmahesh567
Starting Member
2 Posts |
Posted - 2007-08-11 : 22:20:20
|
I want to know how I can pass multiple integer parameters to stored procedure which will be used in “in” clause.Following pseudo code does not work.Create stored procedure spTest@intParams int AsSelect * from tableName where ID in (@intParams)EndHere I can not pass multiple parameters to above sp such as “exec spTest 1,2,3”. If I have to convert int parameter to string, how do I convert that string again to int so that I can user those values in above query? |
|
linfangmin
Starting Member
1 Post |
Posted - 2007-08-11 : 22:42:05
|
As far as I know , sqlserver stored procedure not allow array parameters,you can use the dynamic sql,like thisCreate Procedure spTest@intParams Varchar(50)Asdeclare @sql varchar(1024)set @sql = 'Select * from tableName where ID in (' + @intParams + ')'exec(@sql)Go |
|
|
nmahesh567
Starting Member
2 Posts |
Posted - 2007-08-11 : 23:09:30
|
I do not want to use dynamic query. I am looking for the solution by which I can convert string parameter to int values to be used in "in" clause. |
|
|
jsmith8858
Dr. Cross Join
7423 Posts |
|
madhivanan
Premature Yak Congratulator
22864 Posts |
|
|
|
|