|
|
|
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
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 ) |
|
|