SQL Server生成备份脚本

DECLARE @BackDate nvarchar(50) =replace(replace(replace(convert(varchar,getdate(),20),'-',''),' ',''),':','')
SELECT 'backup database '+name+' to disk=''F:\backup\'+name+'\'+name+'_'+@BackDate+'.bak'' with buffercount = 6, maxtransfersize = 2097152 ,compression,noformat,noinit,NAME=N''完整备份'',skip,norewind,nounload'
FROM sys.sysdatabases 
WHERE NAME not in('master','msdb','tempdb','model','ReportServer','ReportServerTempDB') ORDER BY NAME

你可能感兴趣的:(SQL,Server)