首页 > 代码库 > 数据库作业通用代码
数据库作业通用代码
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,@DeleteFile10 while @@fetch_status=011 begin12 EXECUTE (@DeleteFile)13 EXECUTE (@file)14 EXECUTE (@backup)15 fetch next from datebak into @backup,@file,@DeleteFile16 end17 close datebak18 deallocate datebak19 GO
数据库作业通用代码
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。