While passing a storelist from C# code to a SQL query, I get this error:
Msg 245, Level 16, State 1, Line 5
Conversion failed when converting the varchar value '1,2' to data type int.
Please help me to resolve this.
declare @STORENUM Varchar(100)
set @STORENUM = '1,2'
print @STORENUM
SELECT DISTINCT
STORE_NUM,
ISNULL(LINE_1_ADDR, '') AS LINE_1_ADDR,
ISNULL(LINE_2_ADDR, '') AS LINE_2_ADDR,
ISNULL(LINE_3_ADDR, '') AS LINE_3_ADDR,
CITY_NM, STATE_CD
FROM
Store
WHERE
STORE_NUM IN (CAST(@STORENUM AS INT))