HiveBrain v1.2.0
Get Started
← Back to all entries
patternsqlMinor

Checking when a row was inserted into a table on SQL Server?

Submitted by: @import:stackexchange-dba··
0
Viewed 0 times
serversqlintocheckinginsertedwhenwasrowtable

Problem

Is it possible to check when a specific row was inserted into a specific table in SQL Server ?
The table has an index if this any help.

And I need to do this for an existing table where the row has already being inserted.

Thanks.

Solution

To achieve this retrospectively you could do so by inspecting the contents of the transaction log to identify when the insert occurred, of course you need to have access to the relevant transaction log that contains the details.

Here is a walkthrough of how you would inspect the transaction log to locate a table drop event but the process you would follow is mostly the same.

If auditing of this level is actually something that's required then your best bet is to build it into your overall solution, whether through the use of DML Triggers, CDC or Change Tracking or a customised solution.

Context

StackExchange Database Administrators Q#16806, answer score: 7

Revisions (0)

No revisions yet.