Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase 12»»

Records suddenly disappear from fn_dblog in SQL Server 2008 Expand / Collapse
Author
Message
Posted Friday, March 14, 2014 4:00 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Monday, March 17, 2014 10:07 AM
Points: 6, Visits: 9
Hello,

I have a problem with the records from fn_dblog.

When i make an insert/update/delete the records of the concerning table are shown in fn_dblog but after a little time they suddenly disappear.

Do you have any idea why that happens and how to solve the problem ?

Note : my database recovery mode is set to full, there have been no back up and no recovery done to the database and I am using sql server 2008....

Thank you
Post #1551074
Posted Friday, March 14, 2014 4:10 AM


SSC-Forever

SSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-Forever

Group: General Forum Members
Last Login: Today @ 2:51 PM
Points: 42,756, Visits: 35,850
Because the database has never had a backup, it's behaving as though it's in simple recovery model. A DB in full recovery requires a full backup to initialise the log chain, only after a full backup has been run is the DB actually in full recovery. After that point only log backups will mark the log as reusable (truncate the log).

Because the database is behaving as though it's in simple recovery model, a checkpoint operation will truncate the log, marking VLFs which are no longer needed as inactive. fn_dblog only shows log records in active VLFs.



Gail Shaw
Microsoft Certified Master: SQL Server 2008, MVP
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

We walk in the dark places no others will enter
We stand on the bridge and no one may pass

Post #1551076
Posted Friday, March 14, 2014 5:01 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Monday, March 17, 2014 10:07 AM
Points: 6, Visits: 9
thank you ,

I will try backing up my database and see if the problem is solved.

In the mean while I am doing this because i am asked to check every night who made insert/update/delete to a certain table and check the old data (deleted and updated) or the new data (inserted)

is there a way to do so (maybe a stored procedure..) ?
Post #1551086
Posted Friday, March 14, 2014 5:15 AM


SSC-Forever

SSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-Forever

Group: General Forum Members
Last Login: Today @ 2:51 PM
Points: 42,756, Visits: 35,850
rani_rahbani (3/14/2014)
In the mean while I am doing this because i am asked to check every night who made insert/update/delete to a certain table and check the old data (deleted and updated) or the new data (inserted)


Audit trigger writing into an audit table.

The transaction log is NOT for audit purposes, don't try to use it as such. Go with a trigger or, if this is actually a SQL 2008+ server, CDC, Change Tracking or SQL Audit, whichever meets your needs



Gail Shaw
Microsoft Certified Master: SQL Server 2008, MVP
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

We walk in the dark places no others will enter
We stand on the bridge and no one may pass

Post #1551087
Posted Friday, March 14, 2014 5:31 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Monday, March 17, 2014 10:07 AM
Points: 6, Visits: 9
Ok but the problem is that i have more then 100 tables to audit and check so creating a trigger or CDC is not really a good option.

What is the best practice to use an audit for these 100+ tables without creating commands for every table (perhaps there is an option or a tool that allows me to monitor all the tables on a database and save in case of any insert/update/delete...)

thank you for your help.
Post #1551097
Posted Friday, March 14, 2014 5:38 AM


SSC-Forever

SSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-Forever

Group: General Forum Members
Last Login: Today @ 2:51 PM
Points: 42,756, Visits: 35,850
Trigger/CDC is indeed a good idea. Write a script to auto-create the triggers on all the necessary tables, not that hard to do.


Gail Shaw
Microsoft Certified Master: SQL Server 2008, MVP
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

We walk in the dark places no others will enter
We stand on the bridge and no one may pass

Post #1551099
Posted Monday, March 17, 2014 9:31 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Monday, March 17, 2014 10:07 AM
Points: 6, Visits: 9
thank you for the advice,

I am already trying to create a dynamic trigger.

in the mean while i am trying to get to know fn_dblog() better.
But i noticed a problem in the fuction.
while reading topics related to fn_dblog i noticed that there is a slot ID in fn_dblog that saves the slot ID of the updated record here is my scenario :

A record is updated then another record is deleted that is above the updated record then the slot ID of the updated table has changed but the Slot ID in the fn_dblog stays the same and when i run the procedure it indicates another row that has not been updated
EXAMPLE:
in the students tabel I have four records, record 1 with slot ID = 0, record 2 with slot ID = 1, record 3 with slot ID = 2 and recod 4 with slot ID = 3

I update Record 3 and the saved slot ID in fn_dblog is 2.
I delete Record 2 and the slot ID of Record 3 is now 1 but it stays 2 in fn_dblog.
i run Recover_Modified_Data_Proc it gives me Record 4 (things get more complicated with multiple deletes and updates)
is there any way to rectify this problem ?

Post #1551801
Posted Monday, March 17, 2014 9:35 AM


SSC-Forever

SSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-Forever

Group: General Forum Members
Last Login: Today @ 2:51 PM
Points: 42,756, Visits: 35,850
rani_rahbani (3/17/2014)
I am already trying to create a dynamic trigger.


No, don't try to create triggers which use dynamic SQL to do anything anywhere. That's going to kill performance, maintainability and a bunch more.

Create a procedure which uses the catalog views to create a specific trigger for each table.



Gail Shaw
Microsoft Certified Master: SQL Server 2008, MVP
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

We walk in the dark places no others will enter
We stand on the bridge and no one may pass

Post #1551804
Posted Monday, March 17, 2014 9:42 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Monday, March 17, 2014 10:07 AM
Points: 6, Visits: 9
Ok I am going to do just that...

Relating my other problem do you have any idea about the problem or how to solve it ??
Post #1551809
Posted Monday, March 17, 2014 9:44 AM


SSC-Forever

SSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-Forever

Group: General Forum Members
Last Login: Today @ 2:51 PM
Points: 42,756, Visits: 35,850
I'd have to sit and play with the log for a few hours to figure out what you're describing. It's not documented at all, it changes from version to version, it's not a good thing to base important code on


Gail Shaw
Microsoft Certified Master: SQL Server 2008, MVP
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

We walk in the dark places no others will enter
We stand on the bridge and no one may pass

Post #1551810
« Prev Topic | Next Topic »

Add to briefcase 12»»

Permissions Expand / Collapse