W
William \(Bill\) Vaughn
Experts: Please don't suggest @@Identity to anyone without understanding and
explaining the implications of this advice. While JET is stuck with
@@Identity, it's relatively safe, but the continued use of @@Identity with
SQL Server is questionable at best. While there are some special
circumstances where SCOPE_IDENTITY() isn't the best approach, it should be
recommended as a "first choice". As you know, if a trigger fires or other
code executes that changes a row in any table, the @@Identity value will
change and return a bogus value with potentially disastrous effect. This
might not be a factor for simple systems, but as developers make their
applications more sophisticated, they might inadvertently add a trigger or
other code that will alter the behavior of any number of stored procedures.
Thanks for helping.
--
____________________________________
William (Bill) Vaughn
Author, Mentor, Consultant
Microsoft MVP
www.betav.com/blog/billva
www.betav.com
Please reply only to the newsgroup so that others can benefit.
This posting is provided "AS IS" with no warranties, and confers no rights.
__________________________________
explaining the implications of this advice. While JET is stuck with
@@Identity, it's relatively safe, but the continued use of @@Identity with
SQL Server is questionable at best. While there are some special
circumstances where SCOPE_IDENTITY() isn't the best approach, it should be
recommended as a "first choice". As you know, if a trigger fires or other
code executes that changes a row in any table, the @@Identity value will
change and return a bogus value with potentially disastrous effect. This
might not be a factor for simple systems, but as developers make their
applications more sophisticated, they might inadvertently add a trigger or
other code that will alter the behavior of any number of stored procedures.
Thanks for helping.
--
____________________________________
William (Bill) Vaughn
Author, Mentor, Consultant
Microsoft MVP
www.betav.com/blog/billva
www.betav.com
Please reply only to the newsgroup so that others can benefit.
This posting is provided "AS IS" with no warranties, and confers no rights.
__________________________________