I saw this error in some pages, but in my case, I cannot find the problem here.
The error comes when execute my procedure.
exec sp_executesql N' EXEC UpdateEmployee @EmployeeID, @Status ',N'@EmployeeID bigint,@Status int',@EmployeeID=2,@Status=5
CREATE PROCEDURE UpdateEmployee
(
@EmployeeID BIGINT,
@StatusID int
)
AS
IF @StatusID = 0
BEGIN
SET @StatusID = null
END
UPDATE Employee SET StatusID = @StatusID WHERE EmployeeID = @EmployeeID
GO
I got the following error:
Msg 137, Level 15, State 2, Line 1 Must declare the scalar variable "@StatusID".
My field StatusID on the table employee is of type int and nullable
I didn't forget to declare the variable. In fact, it is an IN parameter of my procedure. So, what's wrong?
UPDATE - FIXED
I realized the problem comes from the query generated by the library. I was using the parameter @Status instead of @StatusID. That was the problem. Thanks for your help.