Solved

how find the last deleted identity value

Posted on 2008-10-16
2
358 Views
Last Modified: 2012-05-05
Hi,
  How to find the last deleted identity column
0
Comment
Question by:srirama_rao
2 Comments
 
LVL 2

Expert Comment

by:EruditeMonkey
ID: 22729550
Hi, Do you mean you want the identity of the last row which was deleted?
If this is the case you can't get it form @@identity as you would for inserts.
You could try adding a delete trigger to the table and retrieving values using some SQL along these lines:
SELECT fieldName FROM Deleted
Deleted is a system generated table containing all of the deleted rows.
0
 
LVL 5

Accepted Solution

by:
Cvijo123 earned 250 total points
ID: 22729848
you can use IDENT_CURRENT( 'table_name' ) wich will give u last ID for that table, so if your last identity ID was 358 and u delete last 2 rows IDENT_CURRENT will return 358

link:
http://msdn.microsoft.com/en-us/library/ms175098.aspx
0

Featured Post

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
CDC and AOG on MS SQL 2012 13 25
where to find DTS instalation package for sql 2014 64 bit 3 11
Get Next number from Stored Procedure 8 23
SQL 2012 clustering 9 13
Why is this different from all of the other step by step guides?  Because I make a living as a DBA and not as a writer and I lived through this experience. Defining the name: When I talk to people they say different names on this subject stuff l…
The Delta outage: 650 cancelled flights, more than 1200 delayed flights, thousands of frustrated customers, tens of millions of dollars in damages – plus untold reputational damage to one of the world’s most trusted airlines. All due to a catastroph…
Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.

828 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question