Guidelines for Using Distributed Queries

As long as the provider supports the required OLE DB interfaces, each class of Transact-SQL statement mentioned in this topic is allowed.

Transact-SQL Statements

The following is a list of the subsets of the Transact-SQL language that are allowed on remote tables accessed through linked server-based names or ad hoc names:

  • All queries that have the standard form of SELECT select_list FROM clause WHERE clause are allowed. The INTO new_table_name clause of SELECT is not allowed when the new_table_name refers to a remote table.
  • In SELECT, INSERT, UPDATE, and DELETE statements, columns in remote tables cannot be qualified with a single-part or four-part table name. The remote tables should be aliased in the FROM clause, and the alias name should be used to qualify the column name.
  • Tables that have xml columns cannot be queried, even if the query accesses non-xml columns of the table.
  • When a large object (LOB) column from a remote table is specified as an item in the select_list of a SELECT statement, the SELECT statement cannot contain an ORDER BY clause.
  • The IS NULL and IS NOT NULL predicates cannot reference LOB columns in a remote table.
  • GROUP BY ALL is not allowed in a distributed query when the query also has a WHERE clause. GROUP BY without specifying ALL is supported.
  • INSERT statements are allowed against remote tables as long as the provider meets the OLE DB requirements for INSERT statements. For more information, see INSERT Requirements for OLE DB Providers.
  • NULL constants cannot be inserted into a timestamp column through a distributed query.
  • $IDENTITY and $ROWGUIDCOL are not supported with distributed queries. Explicit values cannot be inserted into identity columns in remote tables.
  • UPDATE and DELETE statements are allowed against remote tables if the provider meets the OLE DB interface requirements on the specified table. For more information, see UPDATE and DELETE Requirements for OLE DB Providers.
  • A remote table can be updated or deleted through a cursor defined on a distributed query when the remote table is specified in the UPDATE or DELETE statement (UPDATE or DELETE remote_table WHERE CURRENT OF cursor_name) if the provider meets the conditions for updatability on the remote table. For more information, see Using Cursors with Distributed Queries.
  • READTEXT, WRITETEXT, and UPDATETEXT statements are not supported against remote tables.
  • Columns that have large object data types (such as text, ntext, or image) cannot be referenced in update or insert operations if the provider is instantiated outside the SQL Server process, provider option AllowInProcess is 0. For more information, see Configuring OLE DB Providers for Distributed Queries.
  • Data definition language statements such as CREATE, ALTER, or DROP statements are not allowed against linked servers.
  • The EXECUTE statement that specifies a pass-through command is supported against linked servers. This statement can be used to execute stored procedures against providers other than SQL Server.
  • No other database-level operations or statements are allowed on linked servers.

Other Guidelines

The following are some additional restrictions and guidelines:

  • STATIC or INSENSITIVE cursors can reference remote tables. KEYSET cursors can reference remote tables if the OLE DB provider meets certain requirements. For more information about these requirements, see Keyset-Driven Cursors Requirements for OLE DB Providers. No other type of cursor can reference a remote table.
  • Stored procedures are supported only against SQL Server data sources.
  • A connection must have the ANSI_NULLS and ANSI_WARNINGS options set ON before the connection can execute distributed queries. For more information, see SET ANSI_DEFAULTS (Transact-SQL).

See Also

Concepts

Using Transactions with Distributed Queries
Data Type Mapping with Distributed Queries
Distributed Queries

Other Resources

SELECT (Transact-SQL)
EXECUTE (Transact-SQL)

Help and Information

Getting SQL Server 2005 Assistance

Change History

Release History

17 July 2006

New content:
  • Added the entry that states tables that have xml columns cannot be queried.