Skip to content

sql db record number

2008 January 18
by Shannon Lowder

Over on Experts Exchange someone asked, once I insert a record into the table, how can I retrieve the primary key that was just inserted.  This is a topic I covered back in 2005 in my post SQL 101 – System Functions.  In this post I introduced you to @@IDENTITY.  If you are unfamiliar with the @@IDENTITY function, please check out my post.  This is a very useful technique to master!

This system function will tell you the id that was just created for your previous insert statement.  It looks like pollock_d and I were on the same page.  Unfortunately, it took a while before the author chose the expert answer.  Read through the process it took to get to the solution, It definitely shows how competitive some people are about getting credit for answers on Experts Exchange.

So, if you have questions, you’ll certainly get help there!

As for me, as long as you get an answer and understand why the answer works, you’ll learn from it.  That’s all that really matters is people learn a new skill in SQL.  If you have any questions about SQL, send them in.  I’m here to help!

Reference

http://www.experts-exchange.com/Programming/Languages/.NET/Visual_CSharp/Q_23093384.html

No Responses leave one →
  1. Mr Parker permalink
    December 7, 2008

    this has to be one of the best animated movies I have ever seen.

Leave a Reply

Note: You can use basic XHTML in your comments. Your email address will never be published.

Subscribe to this comment feed via RSS