标签:style blog color ar os sp for 数据 div
1 declare @backup nvarchar(500) 2 declare @file nvarchar(500) 3 declare @DeleteFile nvarchar(500) 4 declare datebak cursor for 5 select [bak]=‘backup database ‘+quotename(Name)+‘ to disk =‘‘F:\DabaBaseBackup\BU2\‘+Name+‘\‘+Name+‘_‘+convert(varchar(8),getdate(),112)+‘.bak‘‘ with init‘,[file]=‘master.dbo.xp_create_subdir N‘‘F:\DabaBaseBackup\BU2\‘+Name+‘‘‘‘ 6 ,[DeleteFile]=‘master.dbo.xp_delete_file 0,N‘‘F:\DabaBaseBackup\BU2\‘+Name+‘‘‘,N‘‘bak‘‘,N‘‘‘+convert(varchar(100),DateAdd(Day,-10,GETDATE()),126)+‘‘‘‘ 7 from master..sysdatabases where Name like ‘KR_%‘ 8 open datebak 9 fetch next from datebak into @backup,@file,@DeleteFile 10 while @@fetch_status=0 11 begin 12 EXECUTE (@DeleteFile) 13 EXECUTE (@file) 14 EXECUTE (@backup) 15 fetch next from datebak into @backup,@file,@DeleteFile 16 end 17 close datebak 18 deallocate datebak 19 GO
标签:style blog color ar os sp for 数据 div
原文地址:http://www.cnblogs.com/doNetTom/p/4103705.html