troubleshooting Question

Last identity value inserted in a table ms sql 2005

Avatar of robrodp
robrodpFlag for Mexico asked on
Microsoft SQL Server 2005
12 Comments1 Solution457 ViewsLast Modified:
I have a query that instert a record into a table. Th record has an identity field,id.

As soon as the record has been inserted I need to know the id value some relational purposes.

I can use the max function, but since records will be inserted to by many users I need to make sure that the id I get is the one corresponding to the record inserted, with no cnfusion between 2 records inserted almost simultaneoulsy.

I would like to insert and have sql return unambigously the id of the insterted record.
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 12 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 12 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros