Pages

Wednesday, March 13, 2013

SQL Server Shrink Log File

SELECT name,recovery_model_desc FROM sys.databases
GO 

 Step 1
ALTER DATABASE <Your Database Name> SET RECOVERY SIMPLE; 
ALTER DATABASE WSS_Proposal_Content SET RECOVERY SIMPLE;

Step 2
DBCC SHRINKFILE (<Your Database Name>_log, 5); 
DBCC SHRINKFILE (WSS_Proposal_Content_log, 5);

Step3
ALTER DATABASE <Your Database Name> SET RECOVERY FULL; 
ALTER DATABASE WSS_Proposal_Content SET RECOVERY FULL;


Database 1
Alter database SharePoint_Config set Recovery simple
GO

USE [SharePoint_Config]
GO

DBCC SHRINKFILE (N'SharePoint_Config_log' , 50)
go

Alter database SharePoint_Config set Recovery full
GO


Database 2
Alter database WSS_SESProposal_Content set Recovery simple
GO

USE [WSS_SESProposal_Content]
GO
DBCC SHRINKFILE (N'WSS_SESProposal_Content_log',50)
go

Alter database WSS_SESProposal_Content set Recovery full
GO


Database 3
Alter database WSS_Search_Content set Recovery simple
GO

USE [WSS_Search_Content]
GO
DBCC SHRINKFILE (N'WSS_Search_Content_log',50)
go

Alter database WSS_Search_Content set Recovery full
GO

Find Logical File Name
Declare @LogFileLogicalName sysname
select @LogFileLogicalName=Name from sys.database_files where Type=1
print @LogFileLogicalName

No comments:

Post a Comment