by Nathan
29. March 2009 08:29
I have come across this error when using a Indentity In a stored procedure.
In a stored procedure you need to define the scope indentity in a variable before you can use it in a select statement
So instead of
SELECT * FROM table WHERE id = SCOPE_IDENTITY()
You need to use
SET @var = SCOPE_IDENTITY();
SELECT * FROM table WHERE id = @var
@@IDENTITY will return the last indentity across the whole database whilst SCOPE_IDENTITY() will return only the indentity related to the scope of the operation
2ed6c92d-3201-4659-bedd-59654056b274|0|.0
Tags: sql
SQL