This code is how to send NET SEND messages to all the connected SQL Server users in an NT local area network:
CREATE PROC notify_users(@notification VARCHAR(100) = 'SQL Server shutting down')ASBEGINSET NOCOUNT ONDECLARE @msg VARCHAR(250)DECLARE @hostname sysnameSELECT @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 ENDSET NOCOUNT OFFEND