-- Backup Database Full
USE tempdb
DECLARE @DBNAME NVARCHAR(100) = 'TestDB' --Имя базы
DECLARE @PATH NVARCHAR(300) = 'F:\Backup\TestDB\' --Папка бэкапа
DECLARE @SDATE NVARCHAR(30) = CAST(SYSDATETIME() AS nvarchar(30))
SET @SDATE = REPLACE(@SDATE, ':', '-')
DECLARE @COMMANDBACKUP nVARCHAR(1000) = 'BACKUP DATABASE [' + @DBNAME + '] TO DISK = N''' + @PATH + @DBNAME + '_' + @SDATE +'.BAK'''
SET @COMMANDBACKUP = @COMMANDBACKUP+ ' WITH NOFORMAT, NOINIT, '
SET @COMMANDBACKUP = @COMMANDBACKUP+ ' NAME = N''Full backup'','
SET @COMMANDBACKUP = @COMMANDBACKUP+' SKIP, NOREWIND, NOUNLOAD, COMPRESSION, STATS = 10'
EXECUTE(@COMMANDBACKUP)
Комментариев нет:
Отправить комментарий