Solved

how find the last deleted identity value

Posted on 2008-10-16
2
359 Views
Last Modified: 2012-05-05
Hi,
  How to find the last deleted identity column
0
Comment
Question by:srirama_rao
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

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…
A Stored Procedure in Microsoft SQL Server is a powerful feature that it can be used to execute the Data Manipulation Language (DML) or Data Definition Language (DDL). Depending on business requirements, a single Stored Procedure can return differe…
Using examples as well as descriptions, and references to Books Online, show the documentation available for date manipulation functions and by using a select few of these functions, show how date based data can be manipulated with these functions.
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.

738 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