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 6873375
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T04:03:38+00:00 2026-05-27T04:03:38+00:00

I know databases aren’t supported by CREATE SYNONYM , but I’m looking to achieve

  • 0

I know databases aren’t supported by CREATE SYNONYM, but I’m looking to achieve the functionality this would provide.

We’ve got Database A which contains views to tables on Database B. The trouble is “Database B” isn’t always called “Database B”. We use database projects for deployments, which at the moment fall over with an “Invalid Object Name” error if there isn’t a “Database B”.

The workaround at the moment is to open up the .dbschema file and do a find and replace. I guess another option would be to create a load of table synonyms.

What’s the best way of changing the database a number of views reference without changing each view individually?

Thanks

  • 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-05-27T04:03:38+00:00Added an answer on May 27, 2026 at 4:03 am

    Synonyms are a good way to do this. You have to create the synonyms at the object level though (as you’ve discovered). An easy way to do this would be to write a script that runs through the list of tables in DatabaseB (from your example) and creates a synonym for each one in DatabaseA. Keep the name of the synonym the same so the code in your views doesn’t have to change. For instance, you you have tbl_a, tbl_b, and tbl_c in DatabaseB, you’d want your script to eventually do the following:

    create synonym [otherDb].[tbl_a] for [DatabaseB].[schemaB].[tbl_a]
    create synonym [otherDb].[tbl_b] for [DatabaseB].[schemaB].[tbl_b]
    create synonym [otherDb].[tbl_c] for [DatabaseB].[schemaB].[tbl_c]
    

    Now, in your view code, you’ll always use [otherDb].[tbl_a], [otherDb].[tbl_b], and [otherDb].[tbl_c]. Hope this makes sense.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Following command will let me know the names of databases. $ mysqlshow But how
I'm searching on how to do this but my searches aren't turning up things
I know this is a popular topic, but I've been searching quite a bit
I know there are a few similar questions to this but I just can't
We have several SQL Server 2000 databases (I know, we need to upgrade) that
Does anybody know of any sample databases I could download, preferably in CSV or
I know that systems are using their own time zone databases at different levels.
Does anyone know how function indexes work in databases?
I need to know how much space occupies all the databases inside an SQL
Does anyone know of papers/books/etc. that document patterns for databases? For example, one common

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.