Atlanta Custom Software Development 

 
   Search        Code/Page
 

User Login
Email

Password

 

Forgot the Password?
Services
» Web Development
» Maintenance
» Data Integration/BI
» Information Management
Programming
  Database
Automation
OS/Networking
Graphics
Links
Tools
» Regular Expr Tester
» Free Tools


This stored procedure accepts a message as an input parameter and sends that message to all the currently logged in SQL Server users using NET SEND.

Click here to copy the following block
CREATE PROC notify_users
(
@notification VARCHAR(100) = 'SQL Server shutting down'
)
AS
BEGIN

/*******************************************************************************************************
Purpose: To send NET SEND messages to all the connected SQL Server users in an NT Local Arean Network
Input parameters: Message to be sent
Tested on: SQL Server Version 7.0, SQL Server 2000
*******************************************************************************************************/


SET NOCOUNT ON

DECLARE @msg VARCHAR(250)
DECLARE @hostname sysname

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

WHILE @hostname is not null
  BEGIN
   set @msg='exec master.dbo.xp_cmdshell "net send ' + RTRIM(@hostname) + ' ' + RTRIM(@notification) + ' "'
    EXEC (@msg)
     SELECT @hostname= min(RTRIM(hostname))
   FROM
         master.dbo.sysprocesses (NOLOCK)
   WHERE
         hostname <> ''
       and hostname > @hostname
  END

SET NOCOUNT OFF

END


Submitted By : Nayan Patel  (Member Since : 5/26/2004 12:23:06 PM)

Job Description : He is the moderator of this site and currently working as an independent consultant. He works with VB.net/ASP.net, SQL Server and other MS technologies. He is MCSD.net, MCDBA and MCSE. In his free time he likes to watch funny movies and doing oil painting.
View all (893) submissions by this author  (Birth Date : 7/14/1981 )


Home   |  Comment   |  Contact Us   |  Privacy Policy   |  Terms & Conditions   |  BlogsZappySys

© 2008 BinaryWorld LLC. All rights reserved.