declare @bakfile varchar(30), @bakfilediff varchar(30),@pathfull varchar(50),@pathdiff varchar(50)
set @bakfile=‘hp‘+CONVERT(varchar(10),GETDATE(),112)+‘.bak‘
set @bakfilediff=‘hpdiff‘+CONVERT(varchar(10),GETDATE(),112)+‘.bak‘
set @pathfull=‘c:\bak\‘[email protected] --定义全备路径
set @pathdiff=‘c:\bak\‘[email protected] --定义差异备份路径
backup database hp to [email protected] with differential --差异备份
backup database hp to [email protected] with init --全备 init 用于重写备份设备
若需要时间
replace(convert (varchar(10,getdate(),108),‘:‘,‘‘)
declare @date varchar( 17),@path varchar( 100)
set @date =replace(( replace((replace ((select
CONVERT(varchar (17), getdate(),120 )),‘-‘, ‘‘)),‘ ‘ ,‘‘)), ‘:‘,‘‘ )
select @date
set @path =‘f:\backup\‘+ ‘erp‘+@date +‘.bak‘
select @path
backup database érp to disk=@path with init