I have the following code
declare @code nvarchar
set @code='2/2017,3/2017'
select *
from payroll
where id_code in (@code)
But I am getting an error in the where clause.
I have the following code
declare @code nvarchar
set @code='2/2017,3/2017'
select *
from payroll
where id_code in (@code)
But I am getting an error in the where clause.
If you are using SQL Server 2016 you can use STRING_SPLIT
declare @code nvarchar
set @code='2/2017,3/2017'
select *
from payroll
where id_code in (SELECT value FROM STRING_SPLIT(@code,','))
for older versions of SQL you can use this as a guide T-SQL split string based on delimiter