Snowfun

导航

 


 

 use master 

go
declare @DbName nvarchar(1000) 
declare @BackupSQL nvarchar(1000) 
declare @time nvarchar(12)
set   @time= left(replace(replace( replace(CONVERT(varchar, getdate(), 120 ),'-','')  ,' ',''),':',''),12)
select @time 

declare Cursor_DBname cursor for 
    SELECT [name] FROM master..SYSDATABASES
    where [name]   in ('MRP_WRSDB','MRP_YHMES','ReportServer','ReportServerTempDB','MRP_ERPDBTEST')
    order by [name] 

open Cursor_DBname 
fetch next from Cursor_DBname into @DbName 
while(@@FETCH_STATUS = 0) 
begin 
    select @BackupSQL='Backup DATABASE ['+@DbName+'] to disk=''L:\ERP_DB_Daily_Backup\DB_1357\'+@DbName+'.bak'' with format,COMPRESSION'
    exec(@BackupSQL) 
    fetch next from Cursor_DBname into @DbName 
end 
close Cursor_DBname 

DEALLOCATE Cursor_DBname

 

 

 

 

posted on 2014-03-14 13:55  Snowfun  阅读(212)  评论(0)    收藏  举报