is it possible to run a Stored procedure on one server to access a table on another server?

  • is it possible to run a Stored procedure on one server to access a table on another server on the same network?, if so how would you get round the username and password for the second server? would you include that info in the SP?

  • You need to create a linked server using sp_addlinkedserver procedure

    EXEC sp_addlinkedserver

    @server='TestServer',

    @srvproduct='',

    @provider='SQLNCLI',

    @datasrc='YourServer\InstanceName'

    Then, create linker server login

    EXEC sp_addlinkedsrvlogin 'TestServer', 'false', 'sa', 'sa', 'password'

    Thats it.

    Now query the server,

    select * from TestServer.master.dbo.sysobjects

    --Ramesh


  • Hi,

    look at linked servers in BOL.

    Paul

  • many thanks Ramesh and Paul

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

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