How to fetch the last inserted record in a particular table?
Answers were Sorted based on User's Feedback
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 |
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 |
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 |
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 |
Answer / sudhakar sakthivel
select * from tableName where rowid = (select max(rowid)
from tableName);
in oracle
| Is This Answer Correct ? | 2 Yes | 0 No |
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 |
Answer / muskaan
if(ds.Tables["tablename"].Rows.Count>0)
{
ds.Tables{"tablename"].Rows.Count-1;
}
| Is This Answer Correct ? | 3 Yes | 4 No |
Answer / shashi
we get data from this Query
ds.table[0].rows.count-1
| Is This Answer Correct ? | 3 Yes | 5 No |
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 |
How to fetch the last inserted record in a particular table?
10 Answers CarrizalSoft Technologies, Microsoft,
How to sort the data in Datatable
What is dataset and datatable in ado.net?
i have two textboxes one for user name and another for password . i have a table name compare(which contains name,passwod etc.,)my doubt is how compare username textbox with name column and how compare password textbox with passwod column. i want the code
types of Store procedure in Sqlserver2000?
How many major types of connection objects in ADO.NET?
What is the difference between sqlcommand and sqldataadapter?
What is a database provider?
what is a dataset?
what purpose of Indexing creating? directly we can search the reqired row with the help of query?what is the use of indexing?
Explain how to bind the controls(best practice) comboboxes to the data in the dataset?
What are typed and untyped dataset?
Visual Basic (800)
C Sharp (3816)
ASP.NET (3180)
VB.NET (461)
COM+ (79)
ADO.NET (717)
IIS (369)
MTS (11)
Crystal Reports (81)
BizTalk (89)
Dot Net (2435)
Exchange Server (362)
SharePoint (720)
WCF (340)
MS Office Microsoft (6963)
LINQ Language-Integrated Query (317)
WPF (371)
TypeScript (144)
Microsoft Related AllOther (311)