Tuesday, June 15, 2010

Send a Message To All Logged In Users On MS Windows

As a DBA you can send a message to all users logged in to an Oracle database using SQL Script.
you can use this script in some cases like when you want to notify the logged in users to close their session if you want to take the database down for some time for maintenance.

SET trims on
SET trimo on
SET linesize 1800
SET wrap off
SET pagesize 0
SET heading off
SET verify off
SET feedback off
SET flush off
SET time off
Spool d:\message.Bat

SELECT DISTINCT 'Net Send ' || TERMINAL || ' Hello.'
FROM V$SESSION
WHERE USERNAME IS NOT NULL AND TERMINAL IS NOT NULL;

Spool Off

Host d:\message.Bat

exit

1 comment:

tbessi said...

If the Messenger service is disabled your script will not work.