Take the 2-minute tour ×
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

Possible Duplicate:
Why is My SQL Server Transaction Log Growing or Running out of Space?

The transaction log in one of my client's databases is 16GB, when the database itself is only 2MB. I have begun backups of the transaction log and they occur every half an hour.

I have attempted to run DBCC SHRINKFILE (Log,size) but it says all virtual pages are in use.

Does this mean there is an uncommited transaction or something? The file has been this big for a while now. Am I able to somehow truncate the log?

share|improve this question

migrated from stackoverflow.com Nov 8 '11 at 12:48

This question came from our site for professional and enthusiast programmers.

marked as duplicate by jcolebrand Dec 5 '12 at 2:33

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

2 Answers 2

Was the database in FULL recovery but no backups being taken previously? Paul Randall's article Running Out of Transaction Log Space covers the other likely scenarios.

The DMV query below will tell you why the log cannot be truncated. If you're unsure how to interpret the output, add the response to your question.

SELECT
    db.[name] AS [Database Name]
  , db.recovery_model_desc AS [Recovery Model]
  , db.log_reuse_wait_desc AS [Log Reuse Wait Description]
  , ls.cntr_value AS [Log Size (KB)]
  , lu.cntr_value AS [Log Used (KB)]
  , CAST(CAST(lu.cntr_value AS FLOAT) 
    / CAST(ls.cntr_value AS FLOAT) AS DECIMAL(18,2)) * 100 AS [Log Used %]
FROM
    sys.databases AS db
INNER JOIN
    sys.dm_os_performance_counters AS lu
ON  db.name = lu.instance_name
INNER JOIN 
    sys.dm_os_performance_counters AS ls
ON  db.name = ls.instance_name
WHERE
    lu.counter_name LIKE N'Log File(s) Used Size (KB)%'
AND ls.counter_name LIKE N'Log File(s) Size (KB)%'
AND ls.cntr_value > 0
OPTION (RECOMPILE);
share|improve this answer

backup your database

change to simple recovery mode,

change back to full recovery mode

magic

share|improve this answer
1  
Changing to simple recovery and then back is not really necessary... if you care about the backups (i.e. in production) then you can shrink the transaction log immediately after backup, and if you don't care (i.e. a dev/test server) then you can just change the mode to simple and shrink it right away. –  Aaronaught Nov 9 '11 at 3:29
    
This does not provide an answer to the question. To critique or request clarification from an author, leave a comment below their post. –  Max Vernon Oct 16 '12 at 13:43