Solved

how find the last deleted identity value

Posted on 2008-10-16
2
356 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
In this article we will get to know that how can we recover deleted data if it happens accidently. We really can recover deleted rows if we know the time when data is deleted by using the transaction log.
Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties
Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.

867 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now