|
|
|
SSC Rookie
      
Group: General Forum Members
Last Login: Friday, April 26, 2013 12:51 AM
Points: 31,
Visits: 71
|
|
Hi,
Under Sql 2008 I really need to shrink the physical size of the logfile. The database uses full logging but is not currently in use I therefore know all transactions are committed and up to date. Physically the log is about 500mb and I would like to empty it and set it back to about 20mb. I have tried the following but the size will just not go down.
ALTER DATABASE [MyDb] SET RECOVERY SIMPLE GO
DBCC SHRINKFILE('MyDb', 1) GO
DBCC SHRINKFILE (N'MyDb_Log' , 0, TRUNCATEONLY) GO
DBCC SHRINKDATABASE(N'MyDb', 5 ) GO
ALTER DATABASE [MyDb] SET RECOVERY FULL GO Any ideas?
Regards
Dave
|
|
|
|
|
Ten Centuries
      
Group: General Forum Members
Last Login: Today @ 8:12 AM
Points: 1,318,
Visits: 1,764
|
|
SQL will tell you if/why it won't shrink the log:
SELECT log_reuse_wait_desc, * --col name may be a little off, from memory, but it's at least close FROM sys.databases WHERE name = 'yourDbName'
SQL DBA,SQL Server MVP('07, '08, '09) One man with courage makes a majority. Andrew Jackson
|
|
|
|
|
Grasshopper
      
Group: General Forum Members
Last Login: Friday, May 17, 2013 4:33 PM
Points: 21,
Visits: 78
|
|
How to shrink transaction log file: http://bit.ly/XaDOQr
|
|
|
|
|
SSC Rookie
      
Group: General Forum Members
Last Login: Friday, April 26, 2013 12:51 AM
Points: 31,
Visits: 71
|
|
ScottPletcher (1/28/2013) SQL will tell you if/why it won't shrink the log:
SELECT log_reuse_wait_desc, * --col name may be a little off, from memory, but it's at least close FROM sys.databases WHERE name = 'yourDbName'
Thanks, didn't know about that column, however it brings back the value 'NOTHING' when queried.
Could this be anything to do with local resources such as disk space or disk fragmentation? If I restore this database to my local instance and back it up, the resultant .bkp file is a quarter of the size of the backup on the server.
|
|
|
|
|
SSC-Dedicated
           
Group: General Forum Members
Last Login: Today @ 10:16 AM
Points: 37,663,
Visits: 29,915
|
|
Most likely the active portion of the log is at the end of the file.
Try a few 'fake' operations (create a table, populate it and then drop it) interspaced with log backups and checkpoint and try again to shrink.
Gail Shaw Microsoft Certified Master: SQL Server 2008, MVP SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
We walk in the dark places no others will enter We stand on the bridge and no one may pass
|
|
|
|
|
SSC Rookie
      
Group: General Forum Members
Last Login: Friday, April 26, 2013 12:51 AM
Points: 31,
Visits: 71
|
|
SQLALX (1/28/2013) How to shrink transaction log file: http://bit.ly/XaDOQr
Ok, I followed all the steps in that article and it did indeed shrink the logfile down to 1mb. So now I have:
Which produces a backup file of 945mb. So does this sound about right, there is no compression enabled on the server.
|
|
|
|
|
SSC-Dedicated
           
Group: General Forum Members
Last Login: Today @ 10:16 AM
Points: 37,663,
Visits: 29,915
|
|
Grow that log file to something sensible, and make sure that the autogrow settings aren't the default.
Gail Shaw Microsoft Certified Master: SQL Server 2008, MVP SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
We walk in the dark places no others will enter We stand on the bridge and no one may pass
|
|
|
|
|
SSC Rookie
      
Group: General Forum Members
Last Login: Friday, April 26, 2013 12:51 AM
Points: 31,
Visits: 71
|
|
GilaMonster (1/29/2013) Grow that log file to something sensible, and make sure that the autogrow settings aren't the default.
Hi, yes I will. It was just on a test version of this "problem" database.
|
|
|
|