> Jacob Munson wrote: > > Unless someone has created a new record after your insert, > > then you'll get their identity instead. SCOPE_IDENTITY, > > on the other hand, returns the last identity value > > generated for any table in the current session and the > > current scope. So with one, you might get someone > > else's identity, and with the other you might get the > > wrong table. > > Nope that's not true. scope_identity() works on the last table > specified in the current batch.
I actually copied this line from BOL: "SCOPE_IDENTITY, returns the last identity value generated for any table in the current session and the current scope." So it doesn't matter what table you inserted into, it will get the most recent identity field you created for the scope and session. However, I think that's saying the same thing you are. The danger is if you forget and do more than one insert, and then grab scope_identity, which is a dumb programmer mistake not a database problem. ---------------- [INFO] -- Access Manager: This transmission may contain information that is privileged, confidential and/or exempt from disclosure under applicable law. If you are not the intended recipient, you are hereby notified that any disclosure, copying, distribution, or use of the information contained herein (including any reliance thereon) is STRICTLY PROHIBITED. If you received this transmission in error, please immediately contact the sender and destroy the material in its entirety, whether in electronic or hard copy format. Thank you. A2 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Message: http://www.houseoffusion.com/lists.cfm/link=i:4:236974 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4 Donations & Support: http://www.houseoffusion.com/tiny.cfm/54