Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
sheena
Starting Member
45 Posts |
Posted - 2007-04-27 : 09:57:49
|
| Hi,I want to display the last recorded record in the database of SQL SERVER 2005.How can i display it with the select query in the grid view...The database contains the information which is general contact details:NameAddressPhoneEmailHow can i display on the submit click event that ur record is inserted and display details in gridview .How to write it in select query identity??I have already an Identity Column in the Table structure. |
|
|
dinakar
Master Smack Fu Yak Hacker
2507 Posts |
Posted - 2007-04-27 : 11:34:45
|
there is nothing like a first record or last record. If you mean how do get the record that just got isnerted, you can use the SCOPE_IDENTITY() function.CREATE PROC dbo.someProc ( , @ID INT OUTPUT) ASBEGININSERT INTO <table> VALUES <>SELECT @Id = SCOPE_IDENTITY()END Create a parmeter of with direction = output from your front end and retrieve the value of @ID from the proc. Dinakar NethiSQL Server MVP************************Life is short. Enjoy it.************************http://weblogs.sqlteam.com/dinakar/ |
 |
|
|
harsh_athalye
Master Smack Fu Yak Hacker
5581 Posts |
Posted - 2007-04-27 : 11:36:42
|
| One way would be:1. Get SCOPE_IDENTITY() value from the proc which is responsible for inserting the record2. Return this value to front-end from Insert Proc.3. Query the table based on the returned Identity value and show the recordHarsh AthalyeIndia."The IMPOSSIBLE is often UNTRIED" |
 |
|
|
|
|
|