locked
OPENQUERY for update. RRS feed

  • Question

  • User779033375 posted

    Hi All,

    I need to update some data in Linked server.

    query:

    update table1 set column1='value' where conditioncolumn1 in ('1','2','3','4')

    Here we need to user OPENQUERY

    Is below query formation a correct procedure/syntax?

    OPENQUERY

    (

    dbconnectionName,

    'update table1 set column1='value' where conditioncolumn1 in ('1','2','3','4')'

    )

    Tuesday, December 22, 2015 9:19 AM

Answers

  • User1724605321 posted

    Hi saffy ,

    Here we need to user OPENQUERY

    Please refer to OPENQUERY (Transact-SQL) document , it executes the specified pass-through query on the specified linked server , the Syntax will be :

    UPDATE OPENQUERY (OracleSvr, 'SELECT name FROM joe.titles WHERE id = 101') 
    SET name = 'ADifferentName';

    Remarks: OPENQUERY does not accept variables for its arguments. OPENQUERY cannot be used to execute extended stored procedures on a linked server .

    In addition , you could also refer to below article for details about Linked Server:

    https://msdn.microsoft.com/en-us/library/ms188279.aspx .

    Best Regards,

    Nan Yu

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, December 23, 2015 2:49 AM

All replies

  • User1724605321 posted

    Hi saffy ,

    Here we need to user OPENQUERY

    Please refer to OPENQUERY (Transact-SQL) document , it executes the specified pass-through query on the specified linked server , the Syntax will be :

    UPDATE OPENQUERY (OracleSvr, 'SELECT name FROM joe.titles WHERE id = 101') 
    SET name = 'ADifferentName';

    Remarks: OPENQUERY does not accept variables for its arguments. OPENQUERY cannot be used to execute extended stored procedures on a linked server .

    In addition , you could also refer to below article for details about Linked Server:

    https://msdn.microsoft.com/en-us/library/ms188279.aspx .

    Best Regards,

    Nan Yu

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, December 23, 2015 2:49 AM
  • User779033375 posted

    Thank you.

    Wednesday, December 23, 2015 5:55 AM