DECLARE @fileName varchar(100);
DECLARE @dbName varchar(100);
DECLARE @fileDate varchar(20);
set @fileName = 'E:\Backup\';
set @dbName = 'DIGISHOP';
set @fileDate = CONVERT(varchar(20),Getdate(),112);
set @fileName = @fileName + @dbName +'-'+ @fileDate + '.bak';
BACKUP Database @dbName to Disk = @fileName;
==========================
Delet BackUp Database Script
==========================
DECLARE @deletefile VARCHAR(100);
SET @deletefile='DIGISHOP-20180920.bak';
DECLARE @cmd NVARCHAR(MAX) =
'xp_cmdshell ''del "E:\Backup\' + @deletefile + '"''';
EXEC (@cmd)
--========
--xp_cmdshell inable
-- To allow advanced options to be changed.
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
=============================
Schedul Backup Installed Script
=================================
sp_configure 'show advanced options', 1;
GO
RECONFIGURE;
GO
sp_configure 'Agent XPs', 1;
GO
RECONFIGURE
GO
No comments:
Post a Comment
I am Safiqul Islam Tuhin