Alters the default database debugger status of the current debugger session.
DEBUG DATABASE [END]
The DEBUG DATABASE statement makes the current debugger session the default debugger of the connected database.
The DEBUG DATABASE END statement reverses the effect of the DEBUG DATABASE statement.
This statement is only valid after starting a debugger session on the current connection with the DEBUG BEGIN statement. The debugger connection must be a database connection, and the user of the current connection must also be a member of the DB:Admin or DB:Debug groups. There can be only one default debugger for a database. If there is already a default debugger session to the connected database or if the connection is not a database connection, an error will be returned.
After the current debugger session becomes the default debugger of the database, any new connection to the database automatically becomes the debuggee of the current debugger. This feature makes it possible to debug SQL scripts from any application, even when the source code of the application is not available.
// The following script will start a debug session and
// poll the ::DEBUG_CONNECTIONS table until the
// next connection to the database becomes a debuggee.
// Note that the script will run until the execution is
// cancelled or a new connection is made to the database
WHILE 0 = ( SELECT COUNT(*) FROM #::DEBUG_CONNECTIONS WHERE Debugger = 1 ) DO