Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 Generate Insert script for Last inserted record

Author  Topic 

Praveen Kandasamy
Starting Member

4 Posts

Posted - 2015-04-24 : 03:06:09
How to generate insert script of last inserted record in SQL SERVER Table???.. I want use this code for log entry purpose..

Thanx and Advance

Kristen
Test

22859 Posts

Posted - 2015-04-24 : 04:30:08
We record changes to a record in an "Audit Table" by using a TRIGGER on the table.

We do not record the current record (its in the table itself) to save space, we only store the "before" data when a record is changed.

If you do something like that you also need to build a Purge routine to get rid of stale data - perhaps anything older than 6 months. If you will delete a lot of data each time (more than, say, 100,000 rows from a single table) you may need to consider doing it in batches so as not to cause too much log growth, and to not to block other processes for too long.
Go to Top of Page
   

- Advertisement -