Querying different databases

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • plmanikandan@gmail.com

    Querying different databases

    Hi,
    I'm having two databases in the name of n1,n2 having same design
    I want to query both the databases by giving the database name in query
    Databases
    N1
    N2
    Table(both database contains same table)
    Detail
    Table details
    No -int
    Name -varchar(10)


    Now i want to check the detail table in both n1 and n2 using the select
    query
    For that I have written query it is not working
    select * from N1.Detail
    Select * from N2.Detail

    The above query is not working in query analyser,I'm getting error as
    "Invalid object name"
    In query analyser the Northwind database is currently selected, anyway
    I have given the database name it has to query from N1 database. How to
    use a select query with database name?

    Mani

  • othellomy@yahoo.com

    #2
    Re: Querying different databases

    select * from N1..Detail
    Select * from N2..Detail

    plmanikan...@gm ail.com wrote:
    Hi,
    I'm having two databases in the name of n1,n2 having same design
    I want to query both the databases by giving the database name in query
    Databases
    N1
    N2
    Table(both database contains same table)
    Detail
    Table details
    No -int
    Name -varchar(10)
    >
    >
    Now i want to check the detail table in both n1 and n2 using the select
    query
    For that I have written query it is not working
    select * from N1.Detail
    Select * from N2.Detail
    >
    The above query is not working in query analyser,I'm getting error as
    "Invalid object name"
    In query analyser the Northwind database is currently selected, anyway
    I have given the database name it has to query from N1 database. How to
    use a select query with database name?
    >
    Mani

    Comment

    Working...