views:

13

answers:

1

I am trying to take database backup. How can I do that when getdate is being appended with file name with format dd/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 
+1  A: 

@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'
RRUZ
@RRUZ thx it worked out, I didn't know it
Shantanu Gupta