通过作业的方式调用SQL执行自动备份,可以解决忘记备份数据库的问题,记录一下
declare @FileFullName varchar(40); declare @FileName varchar(20); declare @ExecSql varchar(100); --declare @Filesuffix varchar(10); -- @Filesuffix = '.bak'; --set @FileName = convert(varchar(10),GETDATE(),112)+'.bak'; set @FileName = Replace(Replace(Replace(convert(varchar(20),GETDATE(),120),'-',''),':',''),' ','')+'.bak'; --select @FileName; set @FileFullName = 'D:\DBBack\'+@FileName; select @FileFullName; set @ExecSql ='backup database Test to disk='''+@FileFullName +''' with init'; select @ExecSql; exec (@ExecSql);