• Like one of the other poster says, try using a stored proc.

    You can use the OPENROWSET approach to create (in-effect) an on-the-fly linked server for each server connection.

    And then UNION all the individual queries together. This sample works for me -- using just 2 servers. Could easily extend it to five.

    -- List the databases on several different servers

    SELECT A.*

    FROM OPENROWSET('SQLOLEDB', 'SERVERA' ; 'sa' ; 'SAPasswordA',

    'SELECT * FROM master.dbo.sysdatabases') as A

    UNION

    SELECT B.*

    FROM OPENROWSET('SQLOLEDB', 'SERVERB' ; 'sa' ; 'SAPasswordB',

    'SELECT * FROM master.dbo.sysdatabases') as B

    A couple of notes here:

    1. You may not want to use the "SA" -- and even if you do, you probably should not hard-code the SA passwords in your proc [Bad practice]!

    2. You may want to retrieve just the columns you want, and not do the "SELECT *".

    -john