I have created a string of integers like this:
var whereClause = "4,5,6"
I need to use this in the following SQL where
clause, where message.Id
is an int
col
select * from table a where message.Id in (@whereClause)
Running this throws Conversion failed when converting the nvarchar
value '4,5,6' to data type int
.
How would one cast the string, so that it could be used in a WHERE IN
clause?
EDIT Appreciate this could possible be a repeat of a question, but I am using Dapper.NET and couldn't find any examples