Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9306671
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 19, 20262026-06-19T00:13:28+00:00 2026-06-19T00:13:28+00:00

Hello SQL Server experts, I have a strange issue that I’m hoping to get

  • 0

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-19T00:13:30+00:00Added an answer on June 19, 2026 at 12:13 am

    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:

    create database MyDatabase;
    go
    use MyDatabase;
    go
    create synonym [dbo].[MyTable1] for [My-Database].[dbo].[MyTable1];
    create synonym [dbo].[MyView2] for [My-Database].[dbo].[MyView2];
    create synonym [dbo].[MyProc3] for [My-Database].[dbo].[MyProc3];
    ...
    

    Here is a bit of generation script to help with this:

    declare @OldDbName sysname = 'My-Database'
    select 'create synonym ' + quotename(schema_name(schema_id)) + '.' + quotename(name) + ' for '
        + quotename(@OldDbName) + '.' + quotename(schema_name(schema_id)) + '.' + quotename(name) + ';'
    from sys.objects
    where schema_name(schema_id) not in ('sys')
        and type in ('AF', 'FN', 'FS', 'FT', 'IF', 'P', 'PC', 'RF', 'TF', 'U', 'V', 'X')
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hello fellow programmers. I have a SQL Server 2005 query that is taking a
Hello SQL Server engine experts; please share with us a bit of your insight...
Hello I'm doing some data conversion from PostgreSQL to Microsoft SQL Server. So far
I have a very simple mail merge that is connected to an SQL server
Hello I have the next strange problem: I recover the coordinates from a sql
Hello I just publish an app that require a database with Sql Server 2008
Hello I'm trying to insert some XML data into a table on SQL Server
I have the following XML that I'm running in SQL Server, and it breaks,
Hello we have an SQL server application running over a low bandwith connection. We
I have some data stored in an SQL Server XML data column in a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.