SP that sends notifications to connected users in an SQL Server#

Wouldn't it be nice if you have a mechanism to notify users that are connected to your SQL Server? Here's a stored procedure that an help you do that task.

CREATE PROC spSendNetworkNotification
@Message VARCHAR(200)
AS
BEGIN
SET NOCOUNT ON

DECLARE @ShellCommand VARCHAR(350)
DECLARE @MessageSource SYSNAME

SELECT @MessageSource= min(RTRIM(@MessageSource))
FROM master.dbo.sysprocesses (NOLOCK)
WHERE @MessageSource <> ''

WHILE @MessageSource is not null
BEGIN
    SET @ShellCommand='EXEC master.dbo.xp_cmdshell "NET SEND ' + LTRIM(RTRIM(@MessageSource)) + ' ' + LTRIM(RTRIM(@Message)) + ' "'
EXEC (@ShellCommand)
    SELECT @MessageSource= min(RTRIM(@MessageSource))
    FROM master.dbo.sysprocesses (NOLOCK)
    WHERE @MessageSource <> '' and @MessageSource > @MessageSource
END

SET NOCOUNT OFF
END

SQL
Thursday, June 30, 2005 12:10:16 AM (GMT Daylight Time, UTC+01:00) #    Comments [0]  | 

 

Comments are closed.
All content © 2010, Keith Rull
On this page
This site
Calendar
<July 2010>
SunMonTueWedThuFriSat
27282930123
45678910
11121314151617
18192021222324
25262728293031
1234567
Archives
Sitemap
Blogroll OPML
Disclaimer

Powered by: newtelligence dasBlog 2.3.9074.18820

The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.

Send mail to the author(s) E-mail

Theme design by Jelle Druyts


Pick a theme: