Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 Reducing log file size

Author  Topic 

parrot
Posting Yak Master

132 Posts

Posted - 2012-08-27 : 15:36:09
My 2005 sql data base has a log file that is 10 times bigger than my data file. I changed the recovery model to Simple from Full but that will not reduce the size of the log file. The file will be static and will not require full recovery. Is there anyway I can reduce the log file size after changing the recovery mode to Simple?

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2012-08-27 : 16:21:31
Yes you can use DBCC SHRINKFILE.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

parrot
Posting Yak Master

132 Posts

Posted - 2012-08-27 : 18:17:48
Should I specify a target size or just run the DBCC SHRINKFILE myfile as the command? What type of shrinkage can I expect for a logfile that is 1 gb and a data file that is 200 mb? I just want to reduce the logfile as much as possible.
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2012-08-27 : 20:13:40
I would shrink it down to 100MB.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

parrot
Posting Yak Master

132 Posts

Posted - 2012-08-27 : 22:51:44
When I try to execute the shrink command in SQL Server Management Studio, the program aborts. I open up Query Designer and then enter the follow command:

DBCC SHRINKFILE (Mydatabase_Log, 100)

When I click Execute Query, SQL Server Management Studio aborts. Can I not execute this instruction in SQL Server Management Studio?
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2012-08-28 : 00:22:32
Don't do it in query designer. Click the new query button instead. The query designer screen really shouldn't be used.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

prett
Posting Yak Master

212 Posts

Posted - 2012-08-28 : 03:03:23
Please check this article, it has good explanation about this issue: http://recoverdatabase.blogspot.com/2012/04/what-to-do-if-sql-server-log-file.html
Go to Top of Page

parrot
Posting Yak Master

132 Posts

Posted - 2012-08-28 : 10:29:28
I finally found an explanation on the internet on how to execute the DBCC SHRINKFILE command. Basically, you have to click on the New Query menu selection on SQL Server Management Studio rather than open a table and then clicking on Query Designer. You also can right click on the database item and then select Tasks and then Shrink. Thanks to everyone for their advice.
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2012-08-28 : 13:49:12
Yes that's what I said in my post: "Click the new query button instead."

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page
   

- Advertisement -