Another script from DOS but shows alerts

,

Like the one posted before, the use of the SP is like this: proc_alerts 1,18. This will show the first 18 alerts on the system. OR proc_alerts 20,35 will show from 20 to 35. This lets you manage the list without letting go out of the screen.

/*
**proc_alerts
**Muestra las alertas configuradas dentro
**del servidor
**Autor Rodrigo Acosta racosta@iecisa.com.ar
**Fecha 18/09/01
*/
CREATE PROCEDURE proc_alerts
@nro1 tinyint =1,
@nro2 tinyint =18
AS

SET NOCOUNT ON

CREATE TABLE #alertas
	(aid tinyint identity(1,1) not null,
	id tinyint,
	name varchar(200),
	message_id int,
	severity tinyint)

INSERT INTO #alertas
SELECT id,name,message_id,severity FROM msdb..sysalerts

DECLARE @select varchar(300)
SET @select='SELECT CONVERT(VARCHAR(3),aid)+"."+SUBSTRING(name,1,44)+"("+CONVERT(VARCHAR(3),id)+")" AS "Alerta",message_id AS "Mensaje", severity AS "Severidad"
from #alertas WHERE aid BETWEEN '+CONVERT(VARCHAR(3),@nro1)+' AND '+CONVERT(VARCHAR(3),@nro2)

DECLARE @count int
SET @count=(SELECT COUNT(*) FROM #alertas)

PRINT 'Cantidad de alertas en el servidor "'+@@servername+'":'+CONVERT(VARCHAR(3),@count)

EXEC (@select)

DROP TABLE #alertas

Rate

Share

Share

Rate