数据库定时备份
新建一个作业 定时执行下面的存储过程
代码
set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
go
ALTER proc [dbo].[beifen1]
as
declare @date varchar(100),
@time1 varchar(10),
@time2 varchar(10),
@time3 varchar(10),
@time4 varchar(10),
@time5 varchar(10),
@time6 varchar(10)
set @time1=DatePart(year,GetDate())
set @time2=DatePart(month,GetDate())
set @time3=DatePart(day,GetDate())
set @time4=DatePart(hour,Getdate())
set @time5=DatePart(minute,Getdate())
set @time6=DatePart(second,Getdate())
set @date= 'D:\数据备份\dd_db_'+@time1+''+@time2+''+@time3+''+@time4+''+@time5+''+@time6+'.bak'
backup database dd to disk=@date with init
set QUOTED_IDENTIFIER ON
go
ALTER proc [dbo].[beifen1]
as
declare @date varchar(100),
@time1 varchar(10),
@time2 varchar(10),
@time3 varchar(10),
@time4 varchar(10),
@time5 varchar(10),
@time6 varchar(10)
set @time1=DatePart(year,GetDate())
set @time2=DatePart(month,GetDate())
set @time3=DatePart(day,GetDate())
set @time4=DatePart(hour,Getdate())
set @time5=DatePart(minute,Getdate())
set @time6=DatePart(second,Getdate())
set @date= 'D:\数据备份\dd_db_'+@time1+''+@time2+''+@time3+''+@time4+''+@time5+''+@time6+'.bak'
backup database dd to disk=@date with init