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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T02:23:37+00:00 2026-05-20T02:23:37+00:00

So, lets say you have two SQL Server Databases on the same server that

  • 0

So, lets say you have two SQL Server Databases on the same server that reference each others tables in their Views, Functions and Stored Procedures.

You know, things like this:

use database_foo

create view spaghetti
as
select f.col1, c.col2
from fusilli f
inner join database_bar.dbo.conchigli c on f.id = c.id

(I know that cross-database views are not very good practice, but lets just say you’re stuck with it)

Are there any good techniques to avoid ‘hard coding’ the database names?

(So that should you need to occasionally re-point to a different database – for testing perhaps – you don’t need to edit loads of views, fns, sps)

I’m interested in SQL 2005 or SQL 2008 solutions. Cheers.

  • 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-20T02:23:38+00:00Added an answer on May 20, 2026 at 2:23 am

    You can try using Synonyms. That way you can change what the synonym points to without having the change your code.

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

Sidebar

Related Questions

I have two different databases in SQL Server, lets say db1 and db2, and
In sql server, I have two tables (lets say Person and School). I want
Let's say I have two SQL Server databases running on separate machines, call them
I'm using SQL Server 2008. Let's say I have two hypothetical tables like below:
Lets say I have two tables - Cat and Cat owner that are linked
Lets say I have two tables tblA ( tableAID INT IDENTITY(1,1), foo VARCHAR(100)) tblB
Let's say I have two databases with identical tables, but one database's tables contains
Background information Let's say I have two database servers, both SQL Server 2008. One
Lets say i installed two named SQL Server 2008 instances e.g. A and B,
I have a simple SQL Server 2008 database with two tables like this: TableA:

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.