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

Answers were Sorted based on User's Feedback



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

Answer / vimal katiyar

daer Archana your answer is nt complete so this s complete query fr last inserted record fetch from table

select * from <tablename> where id=(select max(id) from <table name>)

Is This Answer Correct ?    32 Yes 2 No

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

Answer / raji22559

CommanObject.CommandText="Select @@Identity";

** 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 ?    18 Yes 8 No

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

Answer / skumar

We can use the query like
SELECT TOP 1 ID FROM table ORDER BY ID DESC

Is This Answer Correct ?    11 Yes 2 No

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

Answer / 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

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

Answer / jk

By using scope_identity

Is This Answer Correct ?    9 Yes 2 No

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

Answer / sudhakar sakthivel

select * from tableName where rowid = (select max(rowid)
from tableName);

in oracle

Is This Answer Correct ?    2 Yes 0 No

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

Answer / neha

Through this statement, we can retrieve the same:

ds.Tables[0].Rows[ds.Tables[0].Rows.Count-1]

Is This Answer Correct ?    1 Yes 0 No

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

Answer / muskaan

if(ds.Tables["tablename"].Rows.Count>0)
{
ds.Tables{"tablename"].Rows.Count-1;
}

Is This Answer Correct ?    3 Yes 4 No

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

Answer / shashi

we get data from this Query

ds.table[0].rows.count-1

Is This Answer Correct ?    3 Yes 5 No

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

Answer / archana

If a table have identity column then u can fetch the last
inserted record through following query:

"select max(ID) from test"

Is This Answer Correct ?    2 Yes 9 No

Post New Answer

More ADO.NET Interview Questions

What is ado.net and its features?

0 Answers  


i making a project using windows application c#, i want to show user name, password, and one button login. i wanna make it with sealed class .how its possible . when i clicked my login button all project should be open. pls cleare me.

1 Answers  


Being fresher How would i answer to the question that what is your salary exception?

4 Answers  


what is sql Injection?

4 Answers   Microsoft,


what purpose of Indexing creating? directly we can search the reqired row with the help of query?what is the use of indexing?

3 Answers  






How do we invoke queries from the application

2 Answers  


What provider ADO.net use by default ?

5 Answers   Accenture, BirlaSoft, Wipro,


Which one of the objects is a high-level abstraction of the connection and command objects in ado.net?

0 Answers  


ADO.NET is Disconnected Architecture. DataReader is connected Architecture, but DataReader is a part of ADO.NET. How is it possible?

3 Answers   Zensar,


can we change the data in dataset? if yes what is the process?

1 Answers   Artech,


Which components of a data provider is used to retrieve, insert, delete, or modify data in a data source?

0 Answers  


What is the difference between sqldatareader and sqldataadapter?

0 Answers  


Categories