Thanks

RE: How to return SCOPE_IDENTITY as integer? by johncr

johncr
Wed Mar 03 17:46:10 CST 2004

Looks like you want it as the return value from a stored procedure
If you save it to a local var then you can return it whenever you need to

DECLARE @ScopeIdentity in
-- perform the inser
SELECT @ScopeIdentity = CAST(SCOPE_IDENTITY() AS INT
-- perform any other task
IF @ScopeIdentity IS NOT NUL
RETURN @ScopeIdentity

This posting is provided "AS IS" with no warranties, and confers no rights.