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_BackupDB_1357'+@DbName+'.bak'' with format,COMPRESSION'
exec(@BackupSQL)
fetch next from Cursor_DBname into @DbName
end
close Cursor_DBname
DEALLOCATE Cursor_DBname
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_BackupDB_1357'+@DbName+'.bak'' with format,COMPRESSION'
exec(@BackupSQL)
fetch next from Cursor_DBname into @DbName
end
close Cursor_DBname
DEALLOCATE Cursor_DBname