Home Microsoft SQL Server DigiMailing iRN Contact
    Keyword



sys.sp_dbmmonitorhelpalert

  No additional text.


Syntax
create procedure sys.sp_dbmmonitorhelpalert
(
	@database_name				sysname,
	@alert_id					int = null
)
as
begin
	set nocount on
	if (is_srvrolemember(N'sysadmin') <> 1 )
        begin
			raiserror(21089, 16, 1)
			return (1)
		end
	if object_id ( N'msdb.dbo.dbm_monitor_alerts', N'U' ) is null
	begin
		raiserror( 32041, 16, 1 )
		return 1
	end
	-- Is this a system database?
	if(@database_name = N'msdb' or @database_name = N'master' or @database_name = N'model' or @database_name = N'tempdb')
	begin
		raiserror( 32050, 16, 1)
		return 1
	end
	-- Does the database exist?
	if not exists (select * from master.sys.databases where name = @database_name)
	begin
		raiserror(15010, 16, 1, @database_name)
		return 1
	end

	declare		@value		int,
				@enabled	bit
	if (@alert_id is null)
	begin
		declare  @results2 table(	-- remove temp table as done in other help sp.
			alert_id		int,
			threshold		int null,
			enabled			bit null
		)
		insert into @results2 select 1, time_behind, enable_time_behind from msdb.dbo.dbm_monitor_alerts where database_id = db_id(@database_name)
		insert into @results2 select 2, send_queue,  enable_send_queue  from msdb.dbo.dbm_monitor_alerts where database_id = db_id(@database_name)
		insert into @results2 select 3, redo_queue,  enable_redo_queue  from msdb.dbo.dbm_monitor_alerts where database_id = db_id(@database_name)
		insert into @results2 select 4, average_delay, enable_average_delay from msdb.dbo.dbm_monitor_alerts where database_id = db_id(@database_name)
		select * from @results2
		
		return 0
	end
	else
	begin
		if(@alert_id < 1 or @alert_id > 5)
		begin
			raiserror( 32036, 16, 1)
			return 1
		end
	
		if @alert_id = 1
		begin
			select @value = time_behind, @enabled = enable_time_behind from msdb.dbo.dbm_monitor_alerts where database_id = db_id(@database_name)
		end
		if @alert_id = 2
		begin
			select @value = send_queue, @enabled = enable_send_queue from msdb.dbo.dbm_monitor_alerts where database_id = db_id(@database_name)
		end
		if @alert_id = 3
		begin
			select @value = redo_queue, @enabled = enable_redo_queue from msdb.dbo.dbm_monitor_alerts where database_id = db_id(@database_name)
		end
		if @alert_id = 4
		begin
			select @value = average_delay, @enabled = enable_average_delay from msdb.dbo.dbm_monitor_alerts where database_id = db_id(@database_name)
		end
		if @alert_id = 5
		begin
			select @value = retention_period from msdb.dbo.dbm_monitor_alerts where database_id = db_id(@database_name)
			set @enabled = null
		end
		select @database_name as 'database_name', @value as 'threshold', @enabled as 'enabled'
		
	end
	return 0
end

 
Last revision 2008RTM
News

  Query a named instance
Sybase+ASE+silent+install
SQL 2008 R2
Deprecated procedures in SQL2008
Reporting Services item-level role definitions
Create all your missing indexes
Converting datetime field
Start MSSQL Server Profiler at time
Replicating MSSQL Server views
Exploring Microsoft Sharepoint
The OLE DB provider "SQLNCLI10" for linked server indicates.
Mobile solar charger
Oracle to SQL Server replication
Cannot insert the value NULL into column
Undocumented Microsoft SQL Server 2008
VMware
Zoekmachine optimalisatie
SQL Servers hidden objects
FckEditor
Flash in Ajax
De hype die AJAX heet
Barcode scannen
MySQL; Gratis, makkelijk en snel!
PHP
sIFR; de combinatie tussen HTML en Flash