Accessing database on linked server

Answered Accessing database on linked server

  • Sunday, January 20, 2013 4:02 PM
     
     
    Hi all, 

    I have two databases. On seperate MS SQL Server. 

    So I linked database A to database B by performing sp_addlinkedserver['B'].

    This works as i can list all the servers and its there using sp_linkedservers

    I can the perform a command like

    select * from B.master.sys.databases and it correctly shows all of the correct databases.

    If I then go to do 

    select * from  ['B'].database.dbo.table1 

    I get an error about an invalid object/object name. Whats wrong? I have tried adding square brackets around all parts and still the same?

All Replies

  • Sunday, January 20, 2013 4:13 PM
     
     

    Could you post the exact query and the exact error message please?


    Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se
  • Sunday, January 20, 2013 4:38 PM
     
     Answered Has Code

    You don't need to give single quote around the names

    try this

    select * from  [B].[database].[dbo].[table1]
    Regards
    satheesh