Remote Servers

You can execute stored procedures on a remote SAP ASE server. The results from the stored procedure appear on the terminal that calls the procedure.

The syntax for identifying a remote server and the stored procedure is:
[execute] server.[database].[owner].procedure_name

You can omit the execute keyword when the remote procedure call (RPC) is the first statement in a batch. If other SQL statements precede the RPC, you must use execute or exec. You must include both the server name and the stored procedure name. If you omit the database name, a search is performed for procedure_name in your default database. If you give the database name, you must also give the procedure owner’s name, unless you own the procedure or the procedure is owned by the database owner.

The following statements execute the stored procedure byroyalty in the pubs2 database located on the GATEWAY server:

Statement

Notes

GATEWAY.pubs2.dbo.byroyalty GATEWAY.pubs2..byroyalty

byroyalty is owned by the database owner.

GATEWAY...byroyalty

Use if pubs2 is the default database.

declare @var int exec GATEWAY...byroyalty

Use when the statement is not the first statement in a batch.

See, Managing Remote Servers, in the System Administration Guide: Volume 1 for information about configuring an SAP ASE server for remote access. A remote server name (GATEWAY in the previous example) must match a server name in your local interfaces file. If the server name in interfaces is in uppercase letters, you must also use uppercase letters in the RPC to match the server name.