Question: How can I Delete using OPENQUERY? Normally for a SELECT from OPENQUERY , I'll do something like :
SELECT col1 ,col2 FROM OPENQUERY (MY_LINKED_SERVER,'SELECT col1,col2 FROM MY_LINKED_TABLE')
Can a similar method be used but for DELETE?
Answer: To use DELETE , it's a similar process to the SELECT but using the DELETE syntax. Taking the SELECT example above - you'll do the following. Note:this example will delete ALL the rows in the linked server table . :
DELETE FROM OPENQUERY (MY_LINKED_SERVER,'SELECT col1,col2 FROM MY_LINKED_TABLE')
Read more on OPENQUERY,Linked Servers and AS400
SQL Server – Datetime date range , AS400 and OPENQUERY (SQL ...
Connect SQL Servers without using Linked Servers
Import Data from AS400 to SQL Server