mjarosz (4/13/2013)
Hello,I have question regarding backup SQL'05.
Please look ta my script :
sqlcmd -S srv_name -U sa -P pass -Q "BACKUP DATABASE Database_name TO DISK = 'D:\Backup\%date%_Database_name.bak' WITH NAME = 'Database_name_backup', FORMAT"
If i remove %Date% backup process will be completed successfully. But with %Date% I ahve folowing error:
Cannot open backup device 'D:\Backup\%date%_Database_name.bak' Date is repleaced by system time...
Please tell me what is wrong...
Thx for help
michal
That is because SQL Server doesn't know what %date% is. It sees it as a string. If you are attempting to write your backups to a directory named with a date value (such as 20130413) you have put that in there by building the string needed for the backup command.