Published on

March 11, 2016

How to Find the Status of Bulk Logging in SQL Server Logs

Backup related questions can sometimes be challenging, especially when it comes to understanding the status of bulk logging operations in SQL Server. In a recent conversation with a DBA friend, he asked me how to determine if a bulk logging operation was performed on his SQL Server. He explained that there were several SSIS jobs running throughout the day and night, and he wanted to identify which log backups contained the bulk logged operation.

While there are various audit settings that can be implemented to capture this information, there is a simpler way to identify the logs with bulk logged operations – by reading the SQL Server logs themselves.

Here is a step-by-step guide on how to find the status of bulk logging in SQL Server logs:

  1. Create a test database:
  2.   CREATE DATABASE MyBulkDB
      GO
      
  3. Change the recovery model to bulk logged:
  4.   USE [master]
      GO
      ALTER DATABASE MyBulkDB SET RECOVERY BULK_LOGGED WITH NO_WAIT
      GO
      
  5. Perform a minimally logged operation:
  6.   USE MyBulkDB
      GO
      CREATE TABLE test (id int)
      GO
      INSERT INTO test values (1)
      GO
      SELECT * INTO test2 FROM test
      GO
      
  7. Revert back to full recovery model:
  8.   USE [master]
      GO
      ALTER DATABASE MyBulkDB SET RECOVERY FULL WITH NO_WAIT
      GO
      
  9. Take a log backup:
  10.   BACKUP LOG [MyBulkDB] TO DISK = N'C:\Data\Bulk1.bak' 
      WITH NOFORMAT, NOINIT,  NAME = N'MyBulkDB-Log Backup', SKIP, NOREWIND, NOUNLOAD,  STATS = 10
      GO
      
  11. Read the backup file headers:
  12.   RESTORE HEADERONLY FROM DISK = N'C:\Data\Bulk1.bak' WITH NOUNLOAD;
      GO
      

When reading the backup file headers, you will notice a column named “HasBulkLoggedData”. If this column is present and set to “1”, it indicates that the log backup contains operations that were minimally logged, even though the database is in the full recovery model.

By utilizing this simple method, you can easily identify which log backups contain bulk logged operations in your SQL Server environment. It’s important to explore and know where to find the information you need, as it can greatly enhance your understanding of SQL Server.

Have you ever encountered a similar situation where you needed to determine the status of bulk logging operations? Share your experiences and let’s learn and grow together!

Click to rate this post!
[Total: 0 Average: 0]

Let's work together

Send us a message or book free introductory meeting with us using button below.