I'm using XML to create a dynamic SQL Query. I need to use the operator IN, but I can't make it work with multiples values.
To illustrate my matter here is what does work :
exec sp_executesql N'SELECT * FROM commercial_element WHERE specific_info IN (@IncludedListB)
',N'@IncludedListB nvarchar(30)',@IncludedListB='BAR'
The parameter @IncludedListB is built as a string in C#
filter.IncludedListB = 'BAR';
What I am trying to do is passing multiple paramters in the operator IN :
exec sp_executesql N'SELECT * FROM commercial_element WHERE specific_info IN (@IncludedListB)
',N'@IncludedListB nvarchar(30)',@IncludedListB='''BAR'',''BSO'''
Building like so :
filter.IncludedListB = ''BAR','BSO'';
Focusing only on the SQL Why does my second query doesn't work ? I'll figure it out for the C#.