How can I acces tables from multiple databases

  • Hi,

    I want to do a select on tables in multiple databases. Can it be done?

    Thanks

    Dinuj


    Thanks and Regards,

    Dinuj Nath

  • Yes, using 3 part naming conventions. This assumes the user has the ability to access the tables in the multiple databases.

    For instance:

    <database>.<owner>.<object name>

    Like the following:

    SELECT *

    FROM Northwind.dbo.Orders

    Or, if multiple tables from different databases at the same time... (this is an example query... you probably don't want to run it due to the cross join, but everything you can do with tables in the same database you can do across databases):

    SELECT *

    FROM Northwind.dbo.Orders

    CROSS JOIN

    pubs.dbo.authors

    K. Brian Kelley
    @kbriankelley

  • Thanks Brian.


    Thanks and Regards,

    Dinuj Nath

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

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