Send message from SQL Server trigger

I need to report a running application (Windows service) when some things happen in SQL Server (2005). Is it possible to send a message from a trigger to an external application on the same system?

+3
source share
7 answers

Or:

  • Use RAISERROR (severity 10) to trigger a warning and set the SQL agent.

  • Download a separate table that is periodically processed by a separate mail processing process. (as suggested by HLGEM)

  • Use the stored procedure to send a message and write to the table.

Each solution separates a transaction trigger from a potentially long messaging call.

0
source

SQL Service Broker, , . . , WAITFOR (RECEIVE) . , .

+15

, DBA , , xp_cmdshell

" . xp_cmdshell."

MS:

CREATE PROC shutdown10
AS
EXEC xp_cmdshell 'net send /domain:SQL_USERS ''SQL Server shutting down 
   in 10 minutes. No more connections allowed.', no_output
EXEC xp_cmdshell 'net pause sqlserver'
WAITFOR DELAY '00:05:00'
EXEC xp_cmdshell 'net send /domain: SQL_USERS ''SQL Server shutting down 
   in 5 minutes.', no_output
WAITFOR DELAY '00:04:00'
EXEC xp_cmdshell 'net send /domain:SQL_USERS ''SQL Server shutting down 
   in 1 minute. Log off now.', no_output
WAITFOR DELAY '00:01:00'
EXEC xp_cmdshell 'net stop sqlserver', no_output
+1

, , , .

, , , , ( , - .) , 5-10 .

0

dbmail. , , , ( sql).

, sql.

XML SQL Server 2005, xml. http://msdn.microsoft.com/en-us/library/ms345123(SQL.90).aspx

0

, , CLR . (.. ), , .

-, MSMQ .

0

, , . , , . , , , , . , .

, ", ", , ( ).

0

All Articles