BUG: @@IDENTITY in Nested Stored Procedure Returns NULLID: Q139620
|
The @@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
Microsoft 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.
The 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
Keywords : kbprg SSrvStProc kbbug6.00 SrvProg
Version : 6.0
Platform : WINDOWS
Issue type :
Last Reviewed: April 19, 1999