Wednesday, July 13, 2011

Shrink Data Base Log file upto 1 mb

Error: SQL Error occurred and current voucher not Saved because some data are not saved
Solution: This type of error occurred n many cases but one major error is lack of space in drive where data base installed , so we have to shrink data log file.but it is critical job to do this on live data
so safe side is to done this task through the query.which is as----
(but use this query on test environment before use)



USE  <DatabaseName>

GO

-- Truncate the log by changing the database recovery model to SIMPLE.

ALTER DATABASE <Name>

SET RECOVERY SIMPLE;

GO



-- Shrink the truncated log file to 1 MB.

DBCC SHRINKFILE (<Name>_Log, 1);

GO



-- Reset the database recovery model.

ALTER DATABASE <Name>

SET RECOVERY FULL;

GO
--------------------------------------------------------------------------------------------------------------------------

No comments:

Post a Comment