Sproc to upd tbl in a different server

  • Hi

    I have 2 servers say Server1, with DB1 and Server2..(DB2).

    In server1,DB1 I would like to write a stored proc that will upd tbl in s2,db2...how can I accomplish this....

    Is it possible to write a sp in s2,db2 and run it from s1,db1

    ..Thanks

  • Assuming you are using linked servers, you should just be able to replace:

    Update Mytable

    Set Myfield = MyData

    FROM Mytable

    WHERE MyCriteria = Something

    With

    Update Server2.Database2.dbo.MyTable

    Set Myfield = MyData

    FROM Server2.Database2.dbo.MyTable

    WHERE MyCriteria = Something

    You don't actually need the FROM if you aren't using any joins, but I'm used to putting it regardless.

    Seth Phelabaum


    Consistency is only a virtue if you're not a screwup. 😉

    Links: How to Post Sample Data[/url] :: Running Totals[/url] :: Tally Table[/url] :: Cross Tabs/Pivots[/url] :: String Concatenation[/url]

  • If you are using linked servers, make sure you have RPC enabled on the linked server and you can perform the following:

    Execute serverb.databaseb.schemab.procedure;

    Jeffrey Williams
    “We are all faced with a series of great opportunities brilliantly disguised as impossible situations.”

    ― Charles R. Swindoll

    How to post questions to get better answers faster
    Managing Transaction Logs

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

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