Can anyone tell me how to write a stored procedure that accepts an array of integers, and then uses that array in an IN
clause?
Is this even possible? All the examples I've seen pass a comma-delimited string, which the stored procedure must parse.
Can anyone tell me how to write a stored procedure that accepts an array of integers, and then uses that array in an IN
clause?
Is this even possible? All the examples I've seen pass a comma-delimited string, which the stored procedure must parse.
Create a user-defined table type:
CREATE TYPE [dbo].[IntArray] AS TABLE (
Val [int] NOT NULL
)
Then use it as a stored procedure parameter:
CREATE Proc demo_type
@aryDemo IntArray
as
SELECT *
FROM MyTable
WHERE ID IN (
SELECT val from @aryDemo
)