Thursday, April 4, 2013

Shrink MS SQL Data Base

Shrink SQL Data Base for reduce the Log File size.


Log to SQL server with Sa account. Run below query with relevant values.

USE <write the database name>;
GO

-- Truncate the log by changing the database recovery model to SIMPLE.
ALTER DATABASE <write the database name>
SET RECOVERY SIMPLE;
GO

-- Shrink the truncated log file to 10 MB.
DBCC SHRINKFILE (<Database Logical Name>, 10);
GO

-- Reset the database recovery model.
ALTER DATABASE <write the database name>
SET RECOVERY FULL;
GO

No comments:

Post a Comment