Hello I'm trying to find the best way in SQL Server 2012 to pass an array to execute a WHERE IN in a stored procedure
Below is my example, I use the variable @GradeFilter to emulate what should come as parameter. It works well if I ave a single element 'A' but if I didn't find the way to define multiple element 'A','B','C'
Thanks for any help
BTW : How can I format the code : Control-K doesn't work, it ask for an hyperlink, So I've used blockQuote but I guess this is not the right way
DECLARE @GradeFilter VARCHAR(MAX)
Item.StockHRK AS HRK
,COUNT(*) AS SQty
,AVG([GRS_SalesEUROPrice]) AS ASV
FROM Hapi.dbo.GRSFeedBack GRS
INNER JOIN Hapi.Dbo.Item on Item.uniquekey=GRS.uniquekey
WHERE GRS_SalesEUROPrice IS NOT NULL
AND GRS_SaleDate BETWEEN '20161201' AND '20170208'
AND (ISNULL(@GradeFilter,'')='' OR GRSGrade IN (@GradeFilter))
GROUP BY Item.StockHRK