DISCONNECT Statement

Ends the connection to the data source.
Valid in: SQL procedure.

Syntax

DISCONNECT FROM <data-source-name> <alias>

Syntax Description

Data-source-name
specifies the data-source-name from which you want to disconnect. The DISCONNECT statement's data-source-name must match the data-source-name that you specified in the CONNECT statement.
Alias
specifies the data source alias from which you want to disconnect. The DISCONNECT statement's alias must match the alias that you specified in the CONNECT statement.

Details

The DISCONNECT statement ends the connection with the data source. If the DISCONNECT statement is omitted, an implicit DISCONNECT is performed when the procedure ends. The SQL procedure continues to execute until you submit a QUIT statement, a SAS procedure, or a DATA step.
The contents of the SQLXRC and SQLXMSG macro variables can be written to the SAS log using the macro. The contents are reset after each pass-through facility statement is executed.
See Return Codes for additional information.

Example: Disconnect and Quit

SQL processing uses the DISCONNECT statement to end the connection with the database. Use the QUIT statement to quit the SQL procedure after the connection ends:
DISCONNECT FROM db;
QUIT;