can I query for a list of linked servers?

  • I have a set of related dbs and I need to do some cross-db queries and I want to do them generically. If I can query for the linked servers and get enough info to build the 4-part names, it'll be better than creating table to hold dsn's separately.

    With all the DMVs in 2008, they gotta have this by now.

    tks much.

  • Yes. You can use sp_linkedservers to return a list of all linked servers on an instance.

    More information...http://msdn.microsoft.com/en-us/library/ms189519(SQL.90).aspx

  • select * from sys.servers where is_linked = 1

  • kevinH-1006814 (7/27/2009)


    I have a set of related dbs and I need to do some cross-db queries and I want to do them generically. If I can query for the linked servers and get enough info to build the 4-part names, it'll be better than creating table to hold dsn's separately.

    With all the DMVs in 2008, they gotta have this by now.

    tks much.

    Why are you using LinkedServers for mere cross-db queries? Are they on different instances?

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

  • Jeff Moden - Wednesday, December 28, 2016 4:20 PM

    kevinH-1006814 (7/27/2009)


    I have a set of related dbs and I need to do some cross-db queries and I want to do them generically. If I can query for the linked servers and get enough info to build the 4-part names, it'll be better than creating table to hold dsn's separately.With all the DMVs in 2008, they gotta have this by now.tks much.

    Why are you using LinkedServers for mere cross-db queries? Are they on different instances?

    Heh... guess he OP is still thinking about that. 😀

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

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

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