Remote connection from within Stored Proc.

  • From within a Stored Proc I need to retrieve data from another SQL Server 2000 DB on another physical server.  I am not allowed to use the login which runs the proc to attach to the other DB and must use a login already provided on that DB.  How can I create a connection for this purpose in the proc by specifying the required login and password ?

  • Use OPENROWSET

     

    _____________
    Code for TallyGenerator

  • Another possibility would be to use a "Linked Server" which would also hide the login and password from prying eyes.

    --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)

  • use the 'Linked Server'. you can use the sp_addlinkedserver [servername]  to add the concerned server and you will be able to connect to any server on any machine

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

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