How to fetch the last inserted record in a particular table?

Answer Posted / nitin kaushik

"select @@identity"
@@identity is used to get the current transaction value .

** Note: Over a given connection if any insert statement is
executed on a table with identity column , the back end
sql-server for the connection initializes a parameter by
name "@@Identity" with the value of Identity column for the
last inserted record.

Is This Answer Correct ?    9 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How can we load multiple tables in to dataset?

798


What are three methods for displaying data in a syncfusion datagrid

819


What are the different layers of ado.net?

748


What is a datagridview?

732


How to aggregating data across related tables?

771


Which database is the ado.net sql connection object designed for?

815


Data reader read and forward only, how is it possible to get 2 tables of data at a time?

680


Can datareader hold data from multiple tables?

867


What two types of data providers does ADO.NET supply? What determines which one you should use?

737


Why edit is not possible in repeater?

699


Compare Data Reader & Dataset in ado.net?

746


Describe ado.net object model in detail.

751


What are the different namespaces used in the project to connect the database? What data providers available in .net to connect to database?

1019


Do you use stored procedure in ado.net?

769


Define the data provider classes that is supported by ado.net?

743