Update Table Query from one server to another

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Syedsql
    New Member
    • Jun 2013
    • 1

    Update Table Query from one server to another

    Hi,

    I have two servers like A and B. Both A and B have same table.Now i want to update the table from A server with table from B server data. IS it possible??
  • ck9663
    Recognized Expert Specialist
    • Jun 2007
    • 2878

    #2
    Yes it's possible.

    You can either create a code or do a replication.

    Good Luck!!!


    ~~ CK

    Comment

    • Maraj
      New Member
      • Nov 2011
      • 24

      #3
      you can write a query like this
      I am supposing you are running this on Server A.
      Code:
      begin tran
      update Table 
      set column=somevalue
      where value=(select value from serverB.DataBasename.dbo.table where value=somevalue)
      This will update value from Server B to Server A
      Last edited by Rabbit; Jun 21 '13, 05:45 PM. Reason: Please use code tags when posting code.

      Comment

      • Rabbit
        Recognized Expert MVP
        • Jan 2007
        • 12517

        #4
        That will only work is the server is set up as a linked server and only if you have the permissions to. At our work, we are not allowed to do this.

        Comment

        • ck9663
          Recognized Expert Specialist
          • Jun 2007
          • 2878

          #5
          And be careful with that syntax, that's an RBAR.

          Good Luck!!!


          ~~ CK

          Comment

          • Sri Ganesh
            New Member
            • Jun 2013
            • 7

            #6
            Hi
            Use this Query,


            Code:
            UPDATE SERVER1TABLE SET SERVER1TABLE.COLUMN1=B.COLUMN1,SERVER1TABLE.COLUMN2=B.COLUMN2
            FROM OPENDATASOURCE('SQLNCLI','DATA SOURCE=SECONDSERVERNAME;UID=XXXX;PWD=XXXXX').DATABASENAME.DBO.SERVER2TABLE AS B
            WHERE B.COLUMN1='XXXX' AND HRMS10EMPLOYEE.COLUMN1='XXXX'

            Regards,
            Sri Ganesh
            Last edited by Rabbit; Jun 25 '13, 03:23 PM. Reason: Please use code tags when posting code.

            Comment

            Working...