DECLARE @dtCurDate datetime
DECLARE @vchCurDate varchar(60)
DECLARE @myPath varchar(128)
SELECT @dtCurDate = GETDATE()
SET @vchCurDate = CAST( @dtCurDate AS varchar(60))
SET @vchCurDate = REPLACE(@vchCurDate, ':', '_')
SET @vchCurDate = REPLACE(@vchCurDate, '.', '_')
SET @vchCurDate = REPLACE(@vchCurDate, ' ', '_')
SET @myPath = 'F:\data\databackup\sino' + @vchCurDate + '.bak'
backup database sinainfo to disk = @myPath WITH INIT
根据需要又做了一些修改:
DECLARE @dtCurDate datetime
DECLARE @vchCurDate varchar(60)
DECLARE @myPath varchar(128)
SELECT @dtCurDate = GETDATE()
SET @vchCurDate = CAST( @dtCurDate AS varchar(60))
SET @VCHcURdate= replace(replace(replace(CONVERT(varchar,@dtCurDate,120 ),'-',''),' ',''),':','')
SET @myPath = 'F:\data\databackup\sino' + @vchCurDate + '.bak'
backup database sinainfo to disk = @myPath WITH INIT
二者的主要区别是生成的备份文件的文件名不同.
阅读(722) | 评论(0) | 转发(0) |