BUG: @@IDENTITY in Nested Stored Procedure Returns NULLLast reviewed: May 2, 1997Article ID: Q139620 |
The information in this article applies to:
SYMPTOMSThe @@identity global variable will be NULL under the following conditions:
Do not query the @@identity global variable from more than one stored procedure nesting level. For example, modify the "add_test1" stored procedure (from example in the following MORE INFORMATION section) to the following code and it works properly:
CREATE PROCEDURE add_test1 AS EXECUTE add_test2 EXECUTE add_test2 RETURN GO STATUSMicrosoft has confirmed this to be a problem in Microsoft SQL Server version 6.0. We are researching this problem and will post new information here in the Microsoft Knowledge Base as it becomes available.
MORE INFORMATIONThe following script shows the @@identity global variable returning a NULL value:
CREATE TABLE test1 ( id int IDENTITY(1,1) NOT NULL , name char (20) NOT NULL ) GO CREATE PROCEDURE add_test2 AS INSERT test1 VALUES ('1') SELECT @@identity RETURN GO CREATE PROCEDURE add_test1 AS EXECUTE add_test2 INSERT test1 VALUES ('2') SELECT @@identity RETURN GO EXECUTE add_test1 GO |
Additional query words: sql6 windows nt sproc sp
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |