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]
server_name is the name of a server that has been defined using sp_addserver.
server_name is a varchar(30) field. If server_name is not defined or is not available, the connection fails, and the procedure is aborted. This parameter is required.
query_buf1 is a query buffer of type char or varchar with a maximum length of 255 bytes. This parameter is required.
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.