Identifying remote servers

You can execute stored procedures on a remote Adaptive Server. The results from the stored procedure display 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 give the server name and the stored procedure name. If you omit the database name, Adaptive Server looks 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 the System Administration Guide for information on setting up Adaptive Server for remote access. A remote server name (GATEWAY in the previous example) must match a server name in your local Adaptive Server’s interfaces file. If the server name in interfaces is in uppercase letters, you must also use uppercase letters in the RPC.