• When you use WHERE ItemCode IN (@Items), SQL Server considers @Items to be a single value. IN (@Item1, @Item2, @Item3) would work, but then you first need to split the list that was passed in into the separate variables.

    Further reading with lots of options and comparisons is here: http://www.sommarskog.se/arrays-in-sql.html


    Hugo Kornelis, SQL Server/Data Platform MVP (2006-2016)
    Visit my SQL Server blog: https://sqlserverfast.com/blog/
    SQL Server Execution Plan Reference: https://sqlserverfast.com/epr/