增量(以日期格式生成文件名.bak)
BACKUP DATABASE ceshi TO
DISK = N'd:\ceshi\backup\ceshi_INCREMENT_.bak'
WITH DIFFERENTIAL , NOFORMAT, NOINIT,
NAME = N'zengliang-Differential Database Backup',
SKIP, NOREWIND, NOUNLOAD, STATS = 10
GO
-------------------------------------------------------------------
完整(以日期格式生成文件名.bak)
use master
go
declare @Database nvarchar(256),@Path nvarchar(2048)
select @Database=N'ceshi',@Path=N'D:/ceshi/backup/' (这里是数据库和,备份地址)
declare @sql nvarchar(max)
select @sql =N'BACKUP DATABASE '+@Database+N'
TO DISK = '''+@Path+@Database+N'_FULL_BACKUP_'+REPLACE(REPLACE(REPLACE(convert(nvarchar(30),getdate(),112),'-','_'),':','_'),'.','_')+N'.bak''
WITH
NOFORMAT,
INIT,
NAME = N''FULL Database Backup'',
SKIP'
exec (@sql)
go
-----------------------------------------------------------------
二次修改增量备份(以日期格式生成文件名.bak)
declare @name varchar(250)
set @name='d:\ceshi\backup\ceshi_INCREMENT_BACKUP_'+ convert(varchar(50),getdate(),112)+'.bak'
BACKUP DATABASE [ceshi]
TO
DISK = @name
WITH
DIFFERENTIAL,
NOFORMAT,
NOINIT,
NAME = N'zengliang-Differential Database Backup',
SKIP,
NOREWIND,
NOUNLOAD,
STATS = 10
GO
-----------------------------------------------------------------