HOW DO YOU SELECT TABLES FROM MULITPLE SQL SERVER DATABASES

  • I am having problems selecting data from multiple Sql Server databases on the same server.  Since you do not have synonyms what do you use to select data from a different database on the same server.

     

     Thanks, that worked.

  • <database>.<owner/schema>.<table>,

    e.g. select * from newdatabase.dbo.table1

    Tim Wilkinson

    "If it doesn't work in practice, you're using the wrong theory"
    - Immanuel Kant

  • Watch out for "odd" table / database  names e.g. we name our databases by year e.g. 2005, 2004, 2006 which means you need to put brackets round them.

    In general, if in doubt use barckets. Checl bol for Delimited Identifiers.

     

  • Agreed. Applies to all other identifiers as well as table and column names.

    Tim Wilkinson

    "If it doesn't work in practice, you're using the wrong theory"
    - Immanuel Kant

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

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