DELETE FROM OPENQUERY

22 May,2019 by Jack Vamvas

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

 


Author: Jack Vamvas (http://www.sqlserver-dba.com)


Share:

Verify your Comment

Previewing your Comment

This is only a preview. Your comment has not yet been posted.

Working...
Your comment could not be posted. Error type:
Your comment has been posted. Post another comment

The letters and numbers you entered did not match the image. Please try again.

As a final step before posting your comment, enter the letters and numbers you see in the image below. This prevents automated programs from posting comments.

Having trouble reading this image? View an alternate.

Working...

Post a comment on DELETE FROM OPENQUERY


sqlserver-dba.com | SQL Server Performance Tuning | SQL Server DBA:Everything | FAQ | Contact|Copyright & Disclaimer