Question: My variable looks like this:

```
DECLARE @number AS NVARCHAR(1000)
SET @number = '1,2,3,4,5,6'

```

What I have in my WHERE statement is this:

```
WHERE V.client IN (@number) 

```

My `V.Client` column is an integer. What I am trying to do is remove the '' from the @number and make it look like 1,2,3,4,5,6. I have tried to do this, 

```
',' + @number + ',' LIKE '%,' + CAST(V.client AS VARCHAR) + ',%'

```

but it only returns results for 1 and not the other numbers. 

Does anyone have any ideas as to what I can do?

Answer: 
Another option

```
DECLARE @number AS nvarchar(1000)
SET @number = '1,2,3,4,5,6'

...
WHERE V.client IN (
                    Select RetVal = B.i.value('(./text())[1]', 'int')
                    From  (Select x = Cast('<x>' + replace(@Number,',','</x><x>')+'</x>' as xml).query('.')) as A 
                    Cross Apply x.nodes('x') AS B(i)
                  )

```

If 2016+, use **string\_split()**
Dynamic sql is the most common option, here's a snippet how to use it 

```
DECLARE @number AS nvarchar(1000)
SET @number = N'1,2,3,4,5,6'

declare @cmd nvarchar(1000) = N'select case when 1 in ' + Quotename(@number, '()') + ' then 1 else 0 end'

exec sp_executesql @cmd

```

which will prepare following query

```
select case when 1 in (1,2,3,4,5,6) then 1 else 0 end

```

Other options you can consider:
Split the string and use standard sql queries. 
In new sql server there is function string\_split which make exacly what you want <https://learn.microsoft.com/en-us/sql/t-sql/functions/string-split-transact-sql?view=sql-server-2017>.
In older versions you can create custom fuction doing exactly the same thing [How do I split a string so I can access item x?](https://stackoverflow.com/questions/2647/how-do-i-split-a-string-so-i-can-access-item-x)