Dbmail and Automation
Introduction:
Automation:
Introduction:
DB Mail is an enterprise solution for sending mails from SQL Server db engine to SMTP servers. SQL Server db applications can communicate with users through Email system. DB Mail is introduced in 2005. It provides the features like scalabillity, security and reliability. DB mail can be used to notify the users or administrators regarding the events raised in SQL Server.
Automation is one of another feature of SQL Server. we can schedule most of the features of SQL Server in order to reduce workload of administrator.
1: What is Service Broker? How to Enable it in MSDB?
It is to establish communication b/w the SQL Server engine and the DB mail engine we need a service broker. It submits the messages to the mail engine. (or) It is a buffering and queuing mechanism maintained by the service broker in SQL Server.
Enable service broker is
ALTER DATABASE [MSDB] SET ENABLE_BROKER WITH NO_WAIT
GO
2: How to Enable db mail feature at server level?
SP_CONFIGURE 'Database Mail XPs', 1
reconfigure
3: How to check whether db mail was configured or not?
sp_configure --> Check Database mail XPs --> 1 or 0 ( If 1 - Enable, 0 - Disable)
4: What are the main components of DB mail and Define it?
Components of DB mail are
- sp_send_dbmail: It is asystem defined stored procedure which is used by SQL Server to send Email by using DB mail feature.
- MSDB Database: It consists of all stored procedure, system tables and db role related to DB mail
- Service Broker:
- databasemail.exe: This file is present in Binn folder of respective instance. it is a db mail engine.
- First you have to Enable db mail feature at server level
- After that Enable Service Broker in MDB db
- then configure mail profile
- Add SMTP account(s)
- Make the profile as private(It can be used by Sysadmin and databasemailuserrole members of MSDB) or public
- set the parameters
- send the mail
Take a new query and execute the below command
SELECT * FROM sysmail_allitems
after that check sent_status column value for your mail.
7: What are the MSDB tables related to DB mail?
- sysmail_profile: It consists of all the profile information
- sysmail_account: It consists of SMTP server accounts information
- sysmail_allitems: It consists of mail sent status. If sent_status is 1 then mail is success otherwise failed.
- sysmail_configuration: It consists of system parameter details.
- EXEC msdb.dbo.sysmail_help_status_sp: To confirm the db mail activation is started
- EXEC msdb.dbo.sysmail_start_sp: To start db mail process manually.
- sysmail_stop_sp/sysmail_start_sp: To stop and start mail queue.
- sysmail_delete_log_sp: stored procedures to permanently delete entries from the DB mail log.
Automation:
9: What is a JOB ?
It is used to implement a series of tasks, which should be performed automatically. JOB can consists of one or more steps.
We can schedule the job.
- To run Continuously
- On demand
- On Schedule
- Agent service was not running
- Network problem
- Server is busy
- Disk Full or No space available
- MSDB is not online
- DNS server was not running
It is graphical tool which displays all the jobs and their status from sysjobactivity table. with this tool.
- we can view properties of job, history, modify job settings, currently running jobs, failed jobs, last out come etc..
- For this go to SQL Server agent --> double click on job activity monitor.
BCP is used to import and export data from a table into file and vice versa.
13:What is mean by an Operator?
Operators are people who will receive the messages from SQL Server db engine when job fails or completes.
14: What is mean by an Alert and what are the types of alerts?
Alerts are important components of SQL agent which provides pro-active database management. Before the problem occurs can start troubleshooting with the help of alerts. when alert is fired it can call a job as well as submit the response to operator.
SQL Server supports 3 types of Alerts.
- Performance condition alerts (These alerts are fired depends on threshold values)
- Event alerts ( These alerts are fired when a run time error occurs)
- WMI alerts
- Automation reduces task of administration and provides pro-active db management .
- It is implemented by SQL Server Agent service and complete information is stored in MSDB database.
- We can implement automation using
- Jobs
- Alerts
- Operators
No comments:
Post a Comment