Sunday, 28 September 2014

SQL job to remove old BizTalk backup files


Run this:

EXEC sp_configure 'show advanced options', 1
GO
-- To update the currently configured value for advanced options.
RECONFIGURE
GO
-- To enable the feature.
EXEC sp_configure 'xp_cmdshell', 1

GO
-- To update the currently configured value for this feature.
RECONFIGURE
GO

Save and schedule this in a sql job:

EXEC xp_cmdshell 'FORFILES /p "D:\Program Files\Microsoft SQL Server\MSSQL11.MSSQLSERVER\MSSQL\Backup" /s /m AU-*.bak /d -1 /c "CMD /C del /Q /F @FILE"'

No comments:

Post a Comment