Connecting to different servers from stored procedures

  • Hi,

    You can use OpenRowSet/OpenQuery to get data from different database located on different server.

    You can write query as:

    SELECTa.*

    FROMa

    INNER JOIN OPENROWSET('SQLOLEDB','ServerAddress';'UserName';'Password',

    'select * from Table

    ') b

    ON a.ID = b.ID

    Note: It might get an error that "Ad Hoc Distributed Queries" is disabled.

    You can enable it by this way:

    Let me know if it helps you in any way.

    Thanks,

    Tejas

    Tejas Shah

  • You can also use linked servers.

    "Keep Trying"

  • execute this before executing the open rowset query.

    EXEC sp_configure 'show advanced options', 1;

    GO

    RECONFIGURE;

    GO

    EXEC sp_configure 'Ad Hoc Distributed Queries', 1;

    GO

    RECONFIGURE;

    GO

  • I'll try these options .....thanks....

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

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