Thursday, 8 May 2014

Ckeck whats using the Log

Ever wnated to truncate a log and found that its in use?  Or that it cant be shrunk, even after a backup.  Well maybe its in use.  Use this to find out...

 DECLARE @DatabaseName VARCHAR(50);
 SET @DatabaseName = '<Databasename>'
 SELECT name, recovery_model_desc, log_reuse_wait_desc
   FROM sys.databases
   WHERE name = @DatabaseName