Strange sql backup behavior

I am trying to automate my backups using osql and the Windows task scheduler. I have run into a strange problem - my database name starts with a number (it is "4DHQ"). The SQL BACKUP command does not work with this database.

I racked my brain using osql and then decided to try it in HQ Administrator. I executed the following SQL"

BACKUP DATABASE 4DHQ TO DISK = 'C:\Documents and Settings\All Users\Documents\RMS BACKUP - HQ.BCK'"

The results were: An error occurred while executing query: Line 1: Incorrect syntax near '4'.

I tried the same string using a different test database (named "TEST") and it worked. Unfortunately, it's not so easy to change my database name now. It this a known bug in SQL?

Jason

Reply to
Jason
Loading thread data ...

Jason

Try putting [ ] around the offending name, i.e. [4DHQ]. SQL server usually does not like tables with spaces and other such issues- likely the same problem. By using the [] you can get it to behave a bit better.

Jerry

Reply to
jph

Amazing. Worked like a charm. Thank you so much.

Try putting [ ] around the offending name, i.e. [4DHQ]. SQL server usually does not like tables with spaces and other such issues- likely the same problem. By using the [] you can get it to behave a bit better.

Jerry

Reply to
Jason

BeanSmart website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.