• What a strange requirement. Not sure what you mean by "old" and "new" identity values. Is the "old" value based on the value of col2? If not this seems completely pointless. The identity value here is what allows to uniquely define a row. Can you explain what the reason for this is? Especially since you are going to delete this table and then populate it with the last two inserted values I question why you even need it in a table. Why not just create a view instead?

    select top 2 col1

    ,col2

    from test1

    order by col1 desc

    This is not prone to error and will ALWAYS be accurate.

    _______________________________________________________________

    Need help? Help us help you.

    Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.

    Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.

    Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
    Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
    Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
    Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/