开发者

Taking Database backup: How to skip '/' from getdate so that it is not considered to be in a folder

开发者 https://www.devze.com 2022-12-27 10:07 出处:网络
I am trying to take database backup. How can I do that when getdate is being appended with file name with format d开发者_如何学运维d/mm/yyyy.

I am trying to take database backup. How can I do that when getdate is being appended with file name with format d开发者_如何学运维d/mm/yyyy.

declare @dbName VARCHAR(100)
declare @path VARCHAR(100)
set @dbName='CallMeIndia'
set @path='F:\'+@dbName +'-'+convert(varchar(50),getdate(),103)+'.bak'
BACKUP DATABASE @dbName
TO DISK= @path 


@Shantanu, a file can't include the / char in the name , try using another format, something like yyyymmdd (112) , you can check this link for more formats.

set @path='F:\'+@dbName +'-'+convert(varchar(50),getdate(),112)+'.bak'
0

精彩评论

暂无评论...
验证码 换一张
取 消