Get the ID of Last Inserted Record in SQL Server
Sometimes you need to know the value of your Primary Key when you insert record in your table. This is true if you have a Master/Detail form and you need to know the Primary key value of the parent table so that you can insert rows in the related table.
Consider the following scenario: