i have a production DB in SQL server and wanted to put the final touches after the functionality is completed. prior to shipping it out i want to make sure i have some clean up in the SQL server DB and truncate and shrink log files?
can i have a nightly job run to truncate logs and shrink files?
this is what i have so far:
ALTER proc [dbo].[UTIL_ShrinkDB_TruncateLog]
as
-- exec sp_helpfile
BACKUP LOG PMIS WITH TRUNCATE_ONLY
DBCC SHRINKFILE (PMIS, 1)
DBCC SHRINKFILE (PMIS, 1)
EDIT:
MY RECOVERY MODEL IS SIMPLE
Since you are performing a Backup on the logfile you shouldn’t have to truncate it. Note that this doesn’t cause the logfile to shrink it just causes it to overwrite itself. So you need to perform them frequently to maintain a small log file.
Here is a good article on log maintenance.
https://web.archive.org/web/20111216163302/https://www.emmet-gray.com/Articles/SQL_LogMaintenance.htm