Hi All
I have the following Stored Procedure that asks for parameter @CaseID in my table that is type INT but how can I insert the values in the parameter when I MUST use string as the variable as the IN statement it only accepts a "," (comma) to sperate the values.
for example
But using the IN statement it accepts multiple values but it needs to be seperated by a comma "," therefor this becomes a string value. The below is the proper syntax for the IN statementCode:CREATEPROCEDURE [dbo].[spEvents] @CaseID nvarchar(10) AS SELECT tblEvents.CaseID FROM tblEvents WHERE (tblEvents.CaseID IN (@CaseID))
so when I goto execute my stored procedure likeCode:SELECT column_name(s) FROM table_name WHERE column_name IN (value1,value2,...)
It comes back with the following errorCode:exec spEvents @CaseID = '21474,21475'
Any ideas on how I can overcome this problem?Code:Msg 245, Level 16, State 1, Procedure spEvents, Line 7 Conversion failed when converting the nvarchar value '21474,2147' to data type int.
So if I use the statement as follows it works fine without the parameter
Code:SELECT tblEvents.CaseID FROM tblEvents WHERE (tblEvents.CaseID IN (21474,21475))




Reply With Quote