First you need to know what you are going to do:
1 each database has its own service BROKER and many SQL Server internal services depend on it
2 Starting SERVICE BROKER requires
1 STOP your SQL Server Agent (that is, SQL Server proxy)
2 ALTER DATABASE Helpdesk2 set Enable_broker (run this script in the script)
Sometimes it's not possible to start your Service Broker because you're not shutting down your SQL SERVER AGENT.
Besides, if you're going to open the broker
You need permission from the administrator .
Second: When you confirm that you have completed the above, the following will be able to enter our long-awaited main process. ↓↓↓
Second: If there is an error. Please follow the steps below.
---I sent myself using Outlook mailbox successfully.
Let's look at the concrete again.
Finally to everyone on the case of a Netizen biography:
Finally, we analyze the email code:
--This example sql:use msdb --used by the mail server go ---does not explain--the following is the normal SQL statement--you have to do anything to write declare @cnt INT; DECLARE @emailBody VARCHAR (4000); SELECT @cnt =count (*) from Ng0002.dbo.secuser; IF @cnt >100 --You can use conditional statements Oh ~~begin SELECT @emailBody = ' database user table records reached: ' +convert (varchar, @cnt); Exec Dbo.sp_send_dbmail --use the configured message name @profile_name = ' sqlmailconfig ',--unclear @recipients = ' [email Protected] ', ---recipient @subject = ' Number of users alert ', --subject @[email protected] --content -- You can also have a query (another code below) end--the above statement means that if the if is set up to send the message, the message is sent to the content. --------Example 2USE msdbgoexec msdb.dbo.sp_send_dbmail@profile_name= ' sqlmailconfig ', @recipients = ' [email protected] ', @ query= ' Select Logid,u_name from Ng0002.dbo.secuser ',--this is a query @subject= ' number of users alert ', @body = ' query results, see attachments ', @attach_query_ Result_as_file =1,--Query results are sent as attachments @query_attachment_filename = ' query results. Txt '--mail attachment name go
In this case, the ability to use SQL to send mail and the problems that may be encountered should all be resolved.
If other questions, please leave a message ~ ~ ~
Reference URL:
Http://www.2cto.com/database/201403/289114.html
http://answers.microsoft.com/zh-hans/outlook_com/forum/oemail-osend/%E8%AF%B7%E9%97%AEoutlookcom%E7%9A%84imap% e6%9c%8d/dbda3ec9-291b-4763-b7f6-793f2724e827
Http://jingyan.baidu.com/article/d713063523564f13fcf47570.html
http://zhangkui.blog.51cto.com/1796259/340557/
SQL Mail Service (solve all kinds of incurable diseases) + case