sp_remotesql allows you to pass native syntax to a remote server. The procedure establishes a connection to a remote server, passes a query buffer, and relays the results back to the client. The syntax for sp_remotesql is as follows:

sp_remotesql server_name, query_buf1
[, query_buf2, ... , query_buf254]


Each additional buffer is char or varchar with a maximum length of 255 bytes. If supplied, these optional arguments are concatenated with the contents of query_buf1 into a single query buffer.


sp_remotesql freds_server, "select @@version"

In this example, the server passes the query buffer to freds_server, which interprets the select @@version syntax and returns version information to the client. The returned information is not interpreted by the server.

For more information on sp_remotesql and its return codes, refer to the Adaptive Server Reference Manual.