Skip to main content

SQL Linked Server Syntax

Useful information if you have a linked server in MS SQL:

SELECT:

select * from openquery(’my_linked_server’, ’select * from table_schema.table_name’)

INSERT:

insert openquery(’my_linked_server, ’select column_1, column2 from table_schema.table_name’) values (’my_value1?, ‘my_value2?)

UPDATE:

update openquery(’my_linked_server, ’select column_1, column_2 from table_schema.table_name where pk = pk_value’) set column_1 = ‘my_value1?, column_2 = ‘my_value2? DELETE:

delete from openquery(’my_linked_server, ’select * from table_schema.table_name where pk = pk_value’)

SQL, T-SQL