Friday, 18 March 2011

How To Reduce Or Delete Log Files From Database


use master
select * from sysdatabases
---For See the database name
BACKUP LOG databasename WITH TRUNCATE_ONLY
---Right Click on Database Go to files And see the DatabaseLog file name
use Database
DBCC SHRINKFILE(DatabaseLog_log,1)
--If my database name is SS
BACKUP LOG SS WITH TRUNCATE_ONLY
DBCC SHRINKFILE(SS1_log,1)

OR
Shrinking a log file to a specified target size

USE AdventureWorks2012;
GO
-- Truncate the log by changing the database recovery model to SIMPLE.
ALTER DATABASE AdventureWorks2012
SET RECOVERY SIMPLE;
GO
-- Shrink the truncated log file to 1 MB.
DBCC SHRINKFILE (AdventureWorks2012_Log, 1);
GO
-- Reset the database recovery model.
ALTER DATABASE AdventureWorks2012
SET RECOVERY FULL;
GO  

No comments:

Post a Comment

Get all non-clustered indexes

DECLARE cIX CURSOR FOR     SELECT OBJECT_NAME(SI.Object_ID), SI.Object_ID, SI.Name, SI.Index_ID         FROM Sys.Indexes SI             ...