Re: Copy identity key in new record in related table.

From: Wm. Scott Miller (Scott.Miller_at_spamkillerwvinsurance.gov)
Date: 01/04/05


Date: Tue, 4 Jan 2005 14:56:45 -0500

Nico:

If you read the BOL on @@IDENTITY you will see it is prone to problems if
something else (like a trigger) inserts another record after you insert one.
You need to use it with the thought in the back of your mind that it might
not work as expected or may lead to a problem in the future if your business
rules change and you need to add objects to your database.

Scott

"Nico Heiligers" <nheiligers@chello.nl> wrote in message
news:%23Fg2fPp8EHA.3028@TK2MSFTNGP10.phx.gbl...
>
> Thanks to you both
> I have tried @@IDENTITY and it worked just fine.
> I will read about the the other two options, in the BOL
>
> Ps what do you mean with
> @@IDENTITY can give you unexpected result?
>
> Regards
> Nico
>
>
>
>
>
> *** Sent via Developersdex http://www.developersdex.com ***
> Don't just participate in USENET...get rewarded for it!



Relevant Pages

  • Re: Trigger is not working when I test
    ... I also can't help wonderining ... why on earth you are using a trigger for something that could be very simply ... CONSTRAINTS in BOL. ... >> the rows that may be changed by the user action. ...
    (microsoft.public.sqlserver.programming)
  • Re: INSERT Trigger
    ... aber in einer (fehlerhaften) Anwendung statt. ... >trigger möglich, siehe BOL. ...
    (microsoft.public.de.sqlserver)
  • Re: Disallowing/Ignoring Insert based on certain column value
    ... Look up "Check Constraints" in BOL. ... > Can anyone help me on writing a trigger that disallows insert into the ...
    (microsoft.public.sqlserver.programming)
  • RE: Trigger is not working when I test
    ... This is from BOL. ... the rows that may be changed by the user action. ... CREATE TRIGGER CheckStock ON ... > When testing I get an error message "invalid object name ...
    (microsoft.public.sqlserver.programming)
  • Re: Trigger and SP
    ... Can you point me to the ref in the BOL? ... SQL Server MVP ... Columnist, SQL Server Professional ... a trigger CAN have a parameter passed FROM it to a stored ...
    (microsoft.public.sqlserver.programming)