My stored procedure accepts a parameter with values like
Declare @Temp VarChar(Max)
Set @Temp = 'S1CW3733|1050105000224,S1CW4923|1050105000009'
Where values is like
Column1|Column2,Column1|Column2,Column1|Column2,
I want to apply same in SQL query like
Select *
From ATMStatus
Where ATM + '|' + Fault IN (@Temp)
How can I achieve this?
Database is SQL Server 2008
For small tables, you can use the table scanning solution, assuming ATM and Fault can never contain comma (
,) or pipe (|):For large tables, you’ll need to employ a splitting function to turn the variable into a multi-row, 2 column table, which would then be used something like: