New Information - SQL Server 2000 SP3.
The DISCONNECT statement disconnects one or all database connections.
DISCONNECT [connection_name | ALL | CURRENT]
Is the connection to be disconnected.
Specifies disconnecting all connections. This option must be used before you can exit the program.
Specifies disconnecting the current connection. The current connection is either the most recent connection established by a CONNECT TO statement or a subsequent connection set by a SET CONNECTION statement.
When a connection is disconnected, all cursors opened for that connection are automatically closed.
To ensure a clean exit, an Embedded SQL program must issue a DISCONNECT ALL statement before it exits the main application.
EXEC SQL CONNECT TO caffe.pubs AS caffe1 USER $integrated; EXEC SQL CONNECT TO latte.pubs AS latte1 USER $integrated; EXEC SQL SET CONNECTION caffe1; EXEC SQL SELECT name FROM sysobjects INTO :name; EXEC SQL SET CONNECTION latte1; EXEC SQL SELECT name FROM sysobjects INTO :name; EXEC SQL DISCONNECT caffe1; EXEC SQL DISCONNECT latte1; // The first select takes place against the pubs // // database on server "caffe." The second SELECT will // // take place against the pubs database on server "latte." // // In place of the two "disconnect" statements at the end, // // you can also write: // // EXEC SQL DISCONNECT ALL; //
Security Note The preceding example uses the $integrated keyword to enable Windows Authentication. When possible, use this authentication method. If Windows Authentication is not available, prompt users to enter their credentials at run time. Avoid storing credentials in a file. If you must persist credentials, you should encrypt them with the Win32 cryptoAPI.