Inserting, Updating, or Deleting Data from Remote Sources in SQL Server

The same techniques used for reading data from remote data sources from within SQL Server can also be applied to executing INSERT, UPDATE, and DELETE statements on the remote data sources.

Using Ad Hoc Connections for Inserting, Updating, and Deleting Data

Both OPENROWSET and OPENDATASOURCE can be used on the INSERT, UPDATE, and DELETE statements to manipulate data on a remote data source.

When using OPENROWSET, you can specify a query to execute or you can specify a fully qualified name referencing the table you would like to update.

The code below shows how to add a new record into an Excel file. (The code in this section is included in the sample files as UsingAdHocToUpdate.sql ...

Get Microsoft® SQL Server™ 2005: Applied Techniques Step by Step now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.