March 02, 2010

How To Shrink / Trunked Database Log on SQL Server 2008

In this occation i want to share my experience as a beginner developer how to Shrinked or Trunked Database Log on SQL server 2008

I Found this script from my best friend that is Mr. Bernerd (Thanks to him), and i thought this is the simplest way to trunked your database log, Ok without to much bull shit..

Try it :
first of all we have to know the Database_Name and the DAtaBase_LogName and i already give you the command to get that "select * from sys.database_files", after that than you can run this script

USE [Database_Name]
GO
Alter Database Database_Name Set Recovery Simple
GO
Alter Database Database_Name Set Recovery Full
GO
DBCC SHRINKFILE ('DAtaBase_LogName', 1)
GO
DBCC SHRINKFILE ('DAtaBase_LogName', 1)
GO
DBCC SHRINKFILE ('DAtaBase_LogName', 1)
GO
DBCC SHRINKFILE ('DAtaBase_LogName', 1)
GO
DBCC SHRINKFILE ('DAtaBase_LogName', 1)
GO
DBCC SHRINKFILE ('DAtaBase_LogName', 1)
GO


Enjoy.....



No comments:

Post a Comment