문제

I want to do this, because I would like to know how many times a particular row has been changed.

Is this possible?

Thanks

도움이 되었습니까?

해결책

Reading the log file either takes a commercial tool, or an incredible amount of SQL internals knowledge to achieve. You can see some of the raw output by using: Select * from ::fn_DBlog(null,null)

Actually decoding to find the same record being altered and ensuring any alteration was committed etc would be a difficult task to put it lightly. So it is 'possible' but not very 'probable' that you will be able to do it.

If you need that functionality within a database then you should be looking at triggers / logic within the code.

다른 팁

Late answer but I hope it will be useful to new readers…

One more function you can try is DBCC LOG but unfortunately this is undocumented function same like fn_dblog.

Problem with transaction log in SQL Server is that it was never meant to be used for this but only to allow point in time recovery and transaction properties.

There is a commercial log reader from ApexSQL that you can try.

Here are also couple similar posts that might get you in the right direction.

Read the log file (*.LDF) in sql server 2008

SQL Server Transaction Log Explorer/Analyzer

Consider using SQL Server 2008.

There is a feature new to SQL Server 2008 called Change Data Capture that does exactly what you require, that is to track data modifications over time.

Looking to inspect the log file in order to track changes is not a wise practice. Doing so will provide you with a limited history, the scope of which would also be dependent on the Recovery Model that you use for your database.

You could "roll your own" solution with a small amount of development, by using a log table and populating it using SQL Server Triggers. The suitability of such a solution is of course dependent on your business case.

Take a look at the following TechNet article for some interesting reading:

Tracking Changes in Your Enterprise Database

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top