SQL Server Transaction Log File (LDF/.ldf)

A log file or LDF(Log Database File) is a database file of Microsoft SQL Server, which stores all the transaction logs/events, which executes on the database. The main purpose of using log file in SQL Server is to rollback the database in case of data loss. Log file uses the same filename as its associated MDF file. The file extension for this file is .ldf.

LDF file is a kind of Log database file.

  • Microsoft SQL Server

Hex: 01 0F 00 00 08 , ASCII

The default location of .ldf file depends on its SQL Server version.

SQL Server 2005

C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\DATA\

SQL Server 2008

C:\Program Files\Microsoft SQL Server\MSSQL10.MSSQLSERVER\MSSQL\DATA\

SQL Server 2008 R2

C:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\DATA\

SQL Server 2012

C:\Program Files\Microsoft SQL Server\MSSQL11.MSSQLSERVER\MSSQL\DATA\

SQL Server 2014

C:\Program Files\Microsoft SQL Server\MSSQL12.MSSQLSERVER\MSSQL\DATA\

SQL Server 2016

C:\Program Files\Microsoft SQL Server\MSSQL13.MSSQLSERVER\MSSQL\DATA\

  • Bad system shutdown
  • Error 9003 – "LOG File Does Not Match the Master Database File"