The sp_passthru procedure allows the user to pass a SQL command buffer to a remote server. The syntax of the SQL statement(s) being passed is assumed to be the syntax native to the class of server receiving the buffer; no translation or interpretation is performed. Results from the remote server are optionally placed in output parameters. The syntax for sp_passthru follows:
sp_passthru server, command, errcode, errmsg, rowcount [, arg1, arg2, ... argn]
server is the name of the server that is to receive the SQL command buffer; the datatype is varchar(30).
command is the SQL command buffer; the datatype is varchar(255).
errcode is the error code returned by the remote server; the datatype is int output.
errmsg is the error message returned by the remote server; the datatype is varchar(255) output.
rowcount is the number of rows affected by the last command in the command buffer; the datatype is int output.
arg1–argn are optional parameters. If provided, these output parameters will receive the results from the last row returned by the last command in the command buffer. The datatypes may vary. All must be output parameters.
sp_passthru ORACLE, "select date from dual", @errcode output, @errmsg output, @rowcount output, @oradate output
This example returns the date from the Oracle server in the output parameter @oradate. If an Oracle error occurs, the error code is placed in @errcode and the corresponding message is placed in @errmsg. The @rowcount parameter is set to 1.
For more information on sp_passthru and its return status, refer to the Adaptive Server Reference Manual.