wdk


Hi all!

I need to check data changes in some tables from specified date. Can it be done without triggers for each table

SQL Server Management Studio always says "Data was changed" if another user updates data and you try to update old version. How it checks data modification date I found only this:

USE [ScheduleDB]

GO

SELECT * FROM sys.objects WHERE object_id = OBJECT_ID('[dbo].[TTest]') AND type in ('U')

but it can only show structure modification date.



Re: Check data changes in table

Arnie Rowland


If you (or the application) know what the previous values were in order to compare them against the current values in the table, you can do it without using TRIGGERs.

Since SSMS has retreived the data and placed it on the screen, SSMS compares the new value against the old value and alerts you to a data change.

However, there is NOT a simple way to 'just check data changes' since some date/time without using a TRIGGER.

In order to just query the table and retreive all data changes since a particular date, you WOULD indeed need a TRIGGER AND a column (perhaps named: [ChangeDate]) to contain the Date/Time of the last update. Then whenever there is a change to the data, the TRIGGER would update the [ChangeDate] column with the current DateTime. At that point, a query would retreive all rows where the [ChangeDate] column is newer than a specified DateTime.







Re: Check data changes in table

wdk

I asked in hope that date of last data changing is stored somewhere in system tables..

So, if only way is comparing data or using triggers/addition columns, let it be.

Thanks for your answer!