locked
what is this? RRS feed

  • Question

  • I'm looking through a stored procedure.
    what is Linked in this statement?
    FROM Linked.ABC.dbo.XYZ

    I know ABC is the database, dbo is the database owner and XYZ is the table name

    How do I get to 'Linked' to look at the tables?
    chuckdawit
    Friday, January 29, 2010 8:56 PM

Answers

  • Hi
    You can use the following procedures to query the metadata:
    EXEC master.dbo.sp_catalogs @server_name = 'MyLinkedServer'
    
     EXEC master.dbo.sp_tables_ex
    			    @table_server = 'MyLinkedServer'
    			    ,@table_name = NULL
    			    ,@table_schema = NULL
    			    ,@table_catalog = 'MyCatalog'
    			    ,@table_type = NULL
    
    • Proposed as answer by Adam Tappis Friday, January 29, 2010 9:55 PM
    • Marked as answer by witdaj Saturday, January 30, 2010 3:19 AM
    Friday, January 29, 2010 9:46 PM

All replies

  • FROM Linked.ABC.dbo.XYZ


    That is called 4-part naming/reference: SERVERNAME.DBNAME.SCHEMANAME.TABLENAME .

    SERVERNAME is a linked server (must be setup previously).




    Kalman Toth, SQL Server 2008 & BI Training, OLAP, SSIS, SSRS; http://www.SQLUSA.com
    • Proposed as answer by Adam Tappis Friday, January 29, 2010 9:55 PM
    Friday, January 29, 2010 9:04 PM
  • Hi
    It seems that Linked is a linked server
    You can find it in sys.servers table
    • Proposed as answer by Adam Tappis Friday, January 29, 2010 9:56 PM
    Friday, January 29, 2010 9:05 PM
  • how do I connect to this linked server to see the tables?

    I can see it in select * from sys.servers, but I don't know how to connect to it.
    chuckdawit
    Friday, January 29, 2010 9:30 PM
  • Make sure that in Object Explorer, it is setup under Linked Servers.

    You can do:

    SELECT * FROM SERVERNAME.DBNAME.SCHEMANAME.TABLENAME

    or

    SELECT * FROM OPENQUERY (SERVERNAME, 'SELECT * FROM DBNAME.SCHEMANAME.TABLENAME')




    Kalman Toth, SQL Server 2008 & BI Training, OLAP, SSIS, SSRS; http://www.SQLUSA.com
    Friday, January 29, 2010 9:36 PM
  • Hi
    You can use the following procedures to query the metadata:
    EXEC master.dbo.sp_catalogs @server_name = 'MyLinkedServer'
    
     EXEC master.dbo.sp_tables_ex
    			    @table_server = 'MyLinkedServer'
    			    ,@table_name = NULL
    			    ,@table_schema = NULL
    			    ,@table_catalog = 'MyCatalog'
    			    ,@table_type = NULL
    
    • Proposed as answer by Adam Tappis Friday, January 29, 2010 9:55 PM
    • Marked as answer by witdaj Saturday, January 30, 2010 3:19 AM
    Friday, January 29, 2010 9:46 PM