Blog of a Filipino Developer about C#, VB.NET, ASP.NET, Java, PHP, SQL Server, MySql and Oracle RSS 2.0
 Thursday, June 30, 2005

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

Wednesday, June 29, 2005 11:10:16 PM (GMT Standard Time, UTC+00:00)  #    Comments [0] -
SQL
Archive
<June 2005>
SunMonTueWedThuFriSat
2930311234
567891011
12131415161718
19202122232425
262728293012
3456789
About the author/Disclaimer

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

© Copyright 2008
Keith Rull
Sign In
Statistics
Total Posts: 246
This Year: 43
This Month: 4
This Week: 0
Comments: 111
Themes
Pick a theme:
Ads
All Content © 2008, Keith Rull
DasBlog theme 'Business' created by Christoph De Baene (delarou)