Tuesday, 3 March 2015

Shrinking of Log File




    Shrinking of log file concept has to be done when we will receive disk space issue, in such scenario we have to follow these steps

  1.  First we have to check why disk space issue is raised like if it is raised due to data file size we have to add extra disk space.
  2. If it is raised due to log file size we have to shrink log file for this check with this below  command  DBCC sqlperf(logspace) it will show from which database is causing the issue.
  3. Then find the data file size and log file size using this stored procedure SP_helpdb <db name>
  4. Here the shrinking is done when the size of the log file  is more than half of the size of data file  ie.,if data file size is 30 mb then the log file size is 15 mb is recommended.
  5. Take one log backup to reduce the usage of log file. 
  6. Next find logical name of that log file by using this stored procedure SP_helpdb <db name> 
  7. Then execute this command use master go DBCC shrinkfile('logfile name', required size in mb)

No comments:

Post a Comment