Friday, January 21, 2011

Shrink Database LDF & MDF Files

Shrink Database LDF File

USE 'ContentDatabase';
GO
BACKUP LOG 'ContentDatabase' WITH TRUNCATE_ONLY;
GO
DBCC SHRINKFILE ('ContentDatabase_log', 100);


Shrink Database MDF File

USE 'ContentDatabase';
GO
SP_HELPDB 'ContentDatabase';
GO
EXEC sp_spaceused @updateusage = 'true';
GO
DBCC SHRINKFILE ('ContentDatabase', 100)
GO
EXEC sp_spaceused

1 comment:

Raj said...

Shrink database ldf file method is the best method for reducing the size of ldf file but sometimes it does not work with MS SQL server 2005.