Home Microsoft SQL Server DigiMailing iRN Contact
    Keyword



sys.sp_dbmmonitordropalert

  No additional text.


Syntax
create procedure sys.sp_dbmmonitordropalert
(
	@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(@alert_id is not null and (@alert_id < 1 or @alert_id > 5) )
	begin
		raiserror( 32036, 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
	if object_id ( N'msdb.dbo.dbm_monitor_alerts', N'U' ) is null
	begin
		raiserror( 32041, 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

	if exists (select * from msdb.dbo.dbm_monitor_alerts where database_id = db_id(@database_name))	--TO DO: cache db_id to local variable
	begin
		if @alert_id is null
		begin
			update msdb.dbo.dbm_monitor_alerts set	time_behind = null, enable_time_behind = null,
													send_queue = null, enable_send_queue = null,
													redo_queue = null, enable_redo_queue = null,
													average_delay = null, enable_average_delay = null
				where database_id = db_id(@database_name)
			return 0
		end
		if @alert_id = 1
		begin
			update msdb.dbo.dbm_monitor_alerts set time_behind = null, enable_time_behind = null where database_id = db_id(@database_name)
			return 0
		end
		if @alert_id = 2
		begin
			update msdb.dbo.dbm_monitor_alerts set send_queue = null, enable_send_queue = null where database_id = db_id(@database_name)
			return 0
		end
		if @alert_id = 3
		begin
			update msdb.dbo.dbm_monitor_alerts set redo_queue = null, enable_redo_queue = null where database_id = db_id(@database_name)
			return 0
		end
		if @alert_id = 4
		begin
			update msdb.dbo.dbm_monitor_alerts set average_delay = null, enable_average_delay = null where database_id = db_id(@database_name)
			return 0
		end
		if @alert_id = 5
		begin
			update msdb.dbo.dbm_monitor_alerts set retention_period = null where database_id = db_id(@database_name) 			
			return 0
		end
	end
	-- Row was not there to drop....	
	return 1
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