Multiple Databases on the same server

  • Hello All,

    I needs some help, I have 6 databases on the same server. The table structure is the same in all the databases. I need to run a query against all 6 databases that will show that Acct Number, Acct Description, Creation Date and Index Number. The result should be displayed in one result window with all 6 databases results.

    Thank you,

  • You can use a UNION to grab all results. Query with the FROM having database.schema.object

    as in

    ...

    FROM db1.dbo.Accounts

  • Something like this

    select * from db1.dbo.table union all

    select * from db2.dbo.table union all

    select * from db3.dbo.table union all

    select * from db4.dbo.table

    -------Bhuvnesh----------
    I work only to learn Sql Server...though my company pays me for getting their stuff done;-)

  • but what if they are having different credentials

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

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