Hello SQL Server experts,
I have a strange issue that I’m hoping to get some feedback on potential solutions for:
I am working with an application which requires an ODBC connection to an existing SQL database. However, the database contains a dash (“-“) in the name, which causes a syntax error in the application (obviously not an outstanding development effort, but there is nothing I can do about this).
As a temporary solution to the problem, I created a copy of the database and renamed it without the dash. This target database is only used for specific tasks and is not updated often, however it does update every few months, which means that I periodically have to go in and refresh it. I was expecting to have a solution from the developer by now, but they are not cooperating.
My question is:
Is there some solution to this issue which wouldn’t involve me having to refresh my copy of the database? I should mention that renaming the original database is not an option. Should I just setup a SQL Job to do a periodic restore of the target database into my copy?
Is a Synonym a possible solution?
Thanks!
EDIT: A couple of people have pointed out the use of square brackets — this is not an option. The application GUI gives me an error when I try to use the brackets in the DB Name field.
Major hack alert – make synonyms not for a database, but everything in it!
If your app only needs access to the objects supported by synonyms, you could potentially create another DB with a better name and fill it with synonyms of the original DB’s objects:
Here is a bit of generation script to help with this: