This script adds an operator 'DBA' AND reports ALL job failures AND alerts TO this Operator. DATABASE Mail OR SQL Mail needs TO be enabled. /*Script to add alerts and notifications to DBA User
Author: SQL Server Specialists
*/
/*First add a operator*/ USE [msdb]
GO DECLARE @OpName VARCHAR (50),
@OpID INT,
@Count INT,
@Recs INT
SET @OpName = 'DBA' /*Check if operator exists*/ SELECT @Recs = COUNT(*)
FROM [msdb].[dbo].[sysoperators] WHERE [name] = @OpName
IF @Recs = 0 BEGIN
EXEC msdb.dbo.sp_add_operator @name= @OpName,
@enabled=1,
@weekday_pager_start_time=90000,
@weekday_pager_end_time=180000,
@saturday_pager_start_time=90000,
@saturday_pager_end_time=180000,
@sunday_pager_start_time=90000,
@sunday_pager_end_time=180000,
@pager_days=0,
@email_address=N'me@myemail.com', -- Amend email address
@category_name=N'[Uncategorized]' END
/*Clear record count*/ SET @Recs = 0
/*Get Operators ID */ SELECT @OpID = ID FROM sysoperators WHERE name = @OpName
/*Add Job Alert Notification*/ UPDATE sysjobs SET [notify_level_email] = 2, [notify_level_eventlog] = 0, [notify_email_operator_id] = @OpID
/*Add Alert notification*/ UPDATE sysalerts SET has_notification = 1
SET @Count = (SELECT MIN(id) FROM sysalerts) WHILE @Count <= (SELECT MAX(id) FROM sysalerts) BEGIN
/*Check Alert exists*/
SELECT @Recs = COUNT(*)
FROM sysnotifications
WHERE alert_id = @Count
/*If alert doesn't exist add*/
IF @Recs = 0
INSERT INTO [msdb].[dbo].[sysnotifications]
([alert_id]
,[operator_id]
,[notification_method])
VALUES
(@Count
,@OpID
,1)
SET @Count = @Count +1
END GO
|
|
|||||||||||||||||||||||||||||||||||||||||||||||||
|
Search
This Month
Recent Articles
Month Archive
Login
|
Script to add alerts and notifications to DBA User - SQL 2005
Keywords:
Alerts
Comments
Re: Script to add alerts and notifications to DBA User - SQL 2005
by
peterson00
on Fri 21 May 2010 07:34 BST | Profile | Permanent Link
Re: Re: Script to add alerts and notifications to DBA User - SQL 2005
It's been great time to read your article, really informative thanks keep it up.
Web Developers India | SEO India Re: Re: Script to add alerts and notifications to DBA User - SQL 2005
by
perfectionnk
on Thu 13 Oct 2011 06:40 BST | Profile | Permanent Link
Thanks for taking the time to post such a detailed and informative article. It has given me a lot of inspiration and I look forward to more like this in the future.
Joomla Web Development | Seo Packages Re: Re: Script to add alerts and notifications to DBA User - SQL 2005
by
Helmore
on Wed 19 Oct 2011 02:47 BST | Profile | Permanent Link
I have to say that the information here was the most complete that I found anywhere. I am definitely bookmarking this to come back and read later.
top ibiza hotels Re: Script to add alerts and notifications to DBA User - SQL 2005
by
peterson00
on Thu 21 Oct 2010 12:10 BST | Profile | Permanent Link
Excellent post.Thanks for sharing such a useful informative post with us...
Australia Jobs Re: Script to add alerts and notifications to DBA User - SQL 2005
by
peterson00
on Thu 23 Dec 2010 05:41 GMT | Profile | Permanent Link
I really like the work that has gone into making the post. I will be sure to tell my blog buddies about your content keep up the good work. Thanks
Mobile phone insurance Re: Script to add alerts and notifications to DBA User - SQL 2005
by
sem
on Wed 24 Aug 2011 06:29 BST | Profile | Permanent Link
Most of the time I don’t make comments on blogs, but I want to mention that this post really forced me to do so. Really nice post! EasyDisplay Plastic Brochure Holders
Re: Script to add alerts and notifications to DBA User - SQL 2005
by
allenmax
on Wed 26 Oct 2011 10:04 BST | Profile | Permanent Link
Laptops are often quieter than desktops, due both to the components (quieter, slower 2.5-inch hard drives) and to less heat production leading to use of fewer and slower cooling fans.
mini laptop computers Re: Script to add alerts and notifications to DBA User - SQL 2005
by
perfectionnk
on Thu 08 Dec 2011 07:42 GMT | Profile | Permanent Link
I suggest this site to my friends so it could be useful & informative for them also. Great effort.
Web Designers London | Website Design Sydney Re: Script to add alerts and notifications to DBA User - SQL 2005
by
allenmax
on Fri 09 Dec 2011 11:57 GMT | Profile | Permanent Link
Marketing your business is an online and offline task. It is best to be armed with techniques in both areas. For your online marketing, include their your website design and your promotional advertisements.
Internet Marketing Service Trackbacks
TrackBack URL: |
||||||||||||||||||||||||||||||||||||||||||||||||