You cannot pass arrays to stored procedures, since arrays do not exist in TSQL. You have several options, I give you two.
Option 1 - Quick and dirty (I do not recommend)
Pass the values ββas a string and add it to the dynamic SQL statement.
CREATE PROCEDURE MyProc @Values varchar(1000) AS DECLARE @SQL VARCHAR(2000) SET @SQL = 'SELECT blahblah WHERE SomeField IN (' + @Values + ')'
Besides the obvious SQL Injection vulnerability, this approach will not work for large collections, and it will not work too well. In addition, it will not work if any value contains a comma. I really do not recommend it, although it may be useful for quick testing.
Option 2 - More Flexible
Save all your values ββin a temporary table that you specify in your stored procedure.
CREATE TABLE
This solution can scale better.
Like others, you can also use a table in memory (which I personally avoid, since I never succeeded with them, they always performed worse than temporary tables) or a table parameter, but you must declare its type in advance.
Diego source share