Conversion failed when converting the varchar value ‘1,2,3′ to data type smallint. I got this error message on SQL Stored Procedure. So what is going on here?

I try to put variable @factory_id ‘1,2,3′ into “SELECT * FROM tempTable WHERE F.Factory_id in (@factory_id )“. But system rejected this code. So what is the solution?

By changing the code to be like this should do the work.

EXEC(‘SELECT * FROM tempTable WHERE F.Factory_id in (‘ + @factory_id +’ )’)

Hope this will help. :D

Related Entries