How to know when the data was last inserted into database/table?

  • Is there a way to find out how to know when the data was last inserted into database/table,

  • If your tables already exist, and your trying to figure out who did it. then Probably not.

    If your designing a solution, then there are a few things you can do.

    For DTS Jobs and such, I have an additional column called Load_Date datetime with a default of getdate(), and that tells me when data was loaded, you could do that do your tables.

    Or you could create Audit tables with triggers that insert rows into your audit table on insert or update or delete. that tells you who did it.

    I'm sure there are other ideas out there too.

  • can you tell me, what exactly i need to run to get the details

  • Have a look at the trace files.

    insert.

    --Trace Files

    SELECT * FROM SYS.TRACES

    When this retruns put in here ..

    --Use this to get the details of the black box

    SELECT * FROM fn_trace_gettable('C:\Program Files\Microsoft SQL Server\MSSQL.7\MSSQL\DATA\xxx.trc', default);

    GO

  • The default trace files generally store information related to configuration options. it will not store any thing related to DML activities.

    generally, if the table is having column with default value of getdate() may be hlpful in getting the answers. but if the the table is not defined with this feature, you will not be able to get information about inserted row date/time.

Viewing 5 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply