Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 MSDE (2000)
 Using @@IDENTITY on 7.0

Author  Topic 

monik
Starting Member

4 Posts

Posted - 2005-07-06 : 12:15:36
Here is my code:

DECLARE @ParentID INT
DECLARE @title NVARCHAR(64)

IF NOT EXISTS ( SELECT ReportItemID FROM ReportItem WHERE (Caption = N'Transaction Reports'))
BEGIN
INSERT INTO dbo.ReportItem
(
Caption,
Description,
FileName,
ParentID,
FactorySet
)
VALUES
(
N'Transaction Reports', -- Caption
N'', -- Description
N'', -- FileName
0, -- ParentID
0 -- FactorySet
)

SET @ParentID = @@IDENTITY

SET @title = N'All Access Attempts'
INSERT INTO dbo.ReportItem
(
Caption,
Description,
FileName,
ParentID,
FactorySet
)
VALUES
(
@title, -- Caption
N'This report shows all access attempts', -- Description
N'TrnHis27.rpt', -- FileName
@ParentID, -- ParentID
0 -- FactorySet
)

END
GO

--------------------------------------------------------------------
Here is the error:
Server: Msg 515, Level 16, State 2, Line 32
Cannot insert the value NULL into column 'ParentID', table 'GeoffreySQL.dbo.ReportItem'; column does not allow nulls. INSERT fails.
The statement has been terminated.

for some reason the variable is not getting the value, why is this. it only happens with 7.0

Kristen
Test

22859 Posts

Posted - 2005-07-06 : 13:14:27
Duplicate of http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=52023
Go to Top of Page
   

- Advertisement -