Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

how find the last deleted identity value

Posted on 2008-10-16
2
Medium Priority
?
368 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 1000 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

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

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

In the first part of this tutorial we will cover the prerequisites for installing SQL Server vNext on Linux.
In part one, we reviewed the prerequisites required for installing SQL Server vNext. In this part we will explore how to install Microsoft's SQL Server on Ubuntu 16.04.
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function
Via a live example, show how to setup several different housekeeping processes for a SQL Server.

971 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