0% found this document useful (0 votes)
6 views2 pages

Log File Troubleshooting Steps in SQL Server 1703006244

Uploaded by

venkataprudhivi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views2 pages

Log File Troubleshooting Steps in SQL Server 1703006244

Uploaded by

venkataprudhivi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Srinivas Merugu

www.linkedin.com/in/srinivas-merugu-dba-azure

Log file troubleshooting steps in SQL server


1. Check the log file size by using below command

DBCC Sqlperf(Logspace)

If log space used % is more than 70% then increase the initial size of Log file or enable the auto
growth when space is available in the drive if auto growth is not enabled.

2. Find the any open transactions are running or not.


DBCC Opentran(DB)

If no open transactions the Shrink the Log file. If log file is unable to shrink then check next step.

3. On log_reuse_wait_desc, column will give the exact information of logfileissue.

i.e it may be due to replication issue or mirroring issue or log backup issue etc.

Select name,log_reuse_wait_desc from sys.databases

4. Request Windows team to add more space on existing drive with capacity team approval.

5. Add T-Log file in another drive and disable auto growth of first log file and enable newly added
logfile if no space on existing drive. We can remove newly added log file once process completed
when clear log file.

1
Srinivas Merugu
www.linkedin.com/in/srinivas-merugu-dba-azure

6. Find the long running transactions and kill after approval.


SP_Who2 active – check blocked by SPID details

DBCC INPUTBUFFER(SPID)

dbcc inputbuffer(58)
If select command then kill the SPID ( Select command is not modify the data)

KILL 58

7. If log backup is required then trigger Log backup and shrink logfile
8. Final option, If recovery model is full change to simple then shrink the log file. Next simple change
to full recovery model then shrink the log file.
9. If issue is frequently occurring during maintenance jobs then add extra drive with proper size and
configuration when no scope to expand existing drive. Detach from one drive and attach the log
file to newly added drive.

10. Below script will help to generate log file shrink for all user database.

DECLARE @ScriptToExecute VARCHAR(MAX);


SET @ScriptToExecute = '';
SELECT
@ScriptToExecute = @ScriptToExecute +
'USE ['+ d.name +']; CHECKPOINT; DBCC SHRINKFILE ('+f.name+');'
FROM sys.master_files f
INNER JOIN sys.databases d ON d.database_id = f.database_id
WHERE f.type = 1 AND d.database_id > 4
-- AND d.name = 'NameofDB'
SELECT @ScriptToExecute ScriptToExecute
EXEC (@ScriptToExecute)

11. If your getting Error 9002: The transaction log for database is full then follow above steps only for
resolve the issue.

You might also like