I have a stored procedure, I want to pass a CSV to it and use this csv in a WHERE IN
clause.
I have done it by passing XML to the stored procedure like this:
WHERE MyColumn IN (SELECT AOS.s.value('(./text())[1]', 'bigint')
FROM (VALUES(@XML))V(X)
CROSS APPLY
V.X.nodes('/ArrayOfLong/long') AOS(s))
Result-wise, this stored procedure works fine, but it's slow. I want to improve the performance. When I run this stored procedure and get the execution plan, I get a warning.
I have also followed this answer, but I cannot use this solution due to permission issues, as mentioned in the comments.
I am looking for a simple clean and optimized solution.
Parameters should be like this '1,2,3,4,5,6,7'
and it will be used like this WHERE IN (1,2,3,4,5,6,7)
Edit: