Solved

how find the last deleted identity value

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Let's review the features of new SQL Server 2012 (Denali CTP3). It listed as below: PERCENT_RANK(): PERCENT_RANK() function will returns the percentage value of rank of the values among its group. PERCENT_RANK() function value always in be…
Entering time in Microsoft Access can be difficult. An input mask often bothers users more than helping them and won't catch all typing errors. This article shows how to create a textbox for 24-hour time input with full validation politely catching …
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
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.

760 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

23 Experts available now in Live!

Get 1:1 Help Now