Shrink SQL Server 2008 Database + Log File Script

Use DatabaseName

– DB shrink

– Get the database free space, decide whether or not to shrinkDB

exec [dbname]. dbo.sp_spaceused

The DBCC SHRINKDB is (DBNAME)

– Log file shrink

Use DatabaseName

GO

Alter Database DatabaseName Set Recovery Simple

GO

Alter Database DatabaseName Set Recovery Full

GO

DBCC SHRINKFILE (‘LogFileName’, 1)

GO

DBCC SHRINKFILE (‘LogFileName’, 1)

GO

DBCC SHRINKFILE (‘LogFileName’, 1)

GO

DBCC SHRINKFILE (‘LogFileName’, 1)
GO

DBCC SHRINKFILE (‘LogFileName’, 1)
GO

DBCC SHRINKFILE (‘LogFileName’, 1)

GO