INSERT INTO table using OpenQuery 1

INSERT INTO table using OpenQuery

TRUNCATE TABLE mytable

INSERT INTO mytable (firstcolumn, secondcolumn)
SELECT firstcolumn, secondcolumn 
FROM OPENQUERY (mylinkedserver, 'SELECT firstcolumn, secondcolumn FROM linkedtable')

Here is what the above code is Doing:
1. It’s creating a table called mytable in the local database.
2. It’s truncating the table.
3. It’s inserting the data from the linked server into the local table.

Similar Posts