How to join 2 databases on same instance

  • I want to join 2 databases on the same instance (Same SQL server machine) but without using alises eg fully qualified name (Prod.dbo.tblwork) and can't use an additional db connection to get at these tables.

    We are using sql server 2000, looking for some sort of aliasing or synonym mechanism that would allow access to tables from database to database in the same sql server instance without using fully qualified names. Is there any way to do this ?

    Thanks

    Sonali Kelkar

  • Not that I know of. Linked server would be the way to handle this normally. Is there a reason that won't work for you?

    Andy

  • Why do you want to do this? (curious). You can't join the tables. Even a linked server requires the FQname. Easiest way is to build views on the tables using FQ name and then join the views.

    Steve Jones

    steve@dkranch.net

  • I have used Views in this manner successfully in the past to cover the following situation:

    I needed to write an extract routine to live in a separate Database from the production data.

    The name of the production database could change from one day to another (don't ask me why, it just did!).

    I created a script that would re-create a set of views based on the supplied dbname. This created views in the format:

    CREATE VIEW VW_titles AS SELECT * FROM titles

    This allowed coding against the view names, removing the link to the fixed db name.

    Hope this info is of some use, even if Steve covered most of it before me.

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply