Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
@@IDENTITY not responding
Message
 
 
To
25/03/2004 08:51:16
General information
Forum:
Microsoft SQL Server
Category:
SQL syntax
Miscellaneous
Thread ID:
00889556
Message ID:
00889580
Views:
19
Change identity assigment because (SELECT @@Identity) creates recordset with one column and row and returns Null.
SET @Table1ID = @@Identity
>I am using several INSERT statments in an INSTEAD OF Trigger on a view. There is more than one table in the view, and they are linked in a simple parent-child relationship.
>
>Variables are declared, and values are set. The problem seems to be with the @@IDENTITY not returning the identity of the insert statment before. I.E.:
>
>INSERT INTO Table1 (Value1, ...)
> VALUES (@Value1, ...)
>
>SET @Table1ID = (SELECT @@Identity)
>
>INSERT INTO Table2 (Table1ID, ...)
> VALUES (@Table1ID, ...)
>
>This gives the error:
>
>Cannot insert the value NULL into column 'Table1ID', table 'dbo.Table2'; column does not allow nulls. Insert fails.
>
>Is there a built in transaction that is nt allowing the actual insert to occur until all inserts are validated, and therefore there is no value for @@IDENTITY? If so, how can I get the identity for the first insert so that I can place it in the next insert statement?
>
>Thank You in advance!
>
>Rollin
--sb--
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform