I have a stored procedure like this:
CREATE PROCEDURE Resume
@UserID nvarchar(100)
AS
BEGIN
SET NOCOUNT ON;
update Candidate set Approved = 'y' where UserId_I in (@UserID)
END
GO
In this the @UserID is in string format. I send the value of parameter @UserID is 1,2,3 from code as string.
I got error as
Conversion failed when converting the nvarchar value '1,2,3' to data type int.
Please solve this
inare logically different from a single string argument that happens to contain commas. SQL, in common with practically every other programming language, won't magically decide to inspect the string and change this. The proper solution to this is to not pass the string in the first place - pass (ideally) a Table-Valued parameter or an XML document - things designed to contain multiple values. No-doubt you'll get answers (or close votes) pointing towards creating a split function on the server, but it's really the wrong approach.