|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
||||
|
||||
|
Using IN predicate in Stored Procedure
Can you use the IN predicate in a stored proc?
Something like this I'm guesing but it doesn't work... CREATE PROCEDURE dbo.g_SomeRows @intRowID int AS Select * from SomeTable WHERE (intRowID IN(@intRowID)) then execute it like this? EXECUTE g_SomeRows 1,2,5,7,19 |
|
#2
|
||||
|
||||
|
Not that way. You can't convert a comma separated list of values into an int data type.
If you know there are only going to be a certain number of elements passed you could do this Example: maximum of 3 values passed Code:
Create Procedure stp_MyProc @param1 int = null, @param2 int = null, @param3 int = null AS SELECT * FROM TableName WHERE ID IN (@param1, @param2, @param3) |
![]() |
| Viewing: ASP Free Forums > Database > Microsoft SQL Server > Using IN predicate in Stored Procedure |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|