Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to send a stored procedure message in SQL Server in format

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

How do I send a stored procedure message in SQL Server in format? Many novices are not very clear about this. In order to help you solve this problem, the following editor will explain it in detail. People with this need can come and learn. I hope you can gain something.

The content of this article is about the method of sending SQL Server stored procedure mail in format (code example), there is a certain reference value, friends in need can refer to, hope to help you.

First, the receipt of e-mail shows:

Second, the stored procedure code part:

BEGIN SET NOCOUNT ON -initialize Declare @ MailTo nvarchar (max) Declare @ MailCc nvarchar (max) Declare @ MailBcc nvarchar (max) Declare @ MailSubject nvarchar (255) Declare @ MailBody nvarchar (max) Declare @ MailFormat nvarchar (20) DECLARE @ SignCount nvarchar (50) -- SELECT @ SignCount=COUNT (1) FROM table name WHERE filter condition + @ SignCount+' frequent 'SET @ MailFormat='HTML' SET @ MailTo='xxx.zzz@qq.com'-- recipient email address SET @ MailCc='xxx.zzz@qq.com' -- CC SET @ MailBcc='xxx.zzz@qq.com'-- BCC SET @ MailBody=''-- send content SET @ MailBody= N'Dear Sir/Madam:

We often have a total of'+ @ SignCount+', please check at that time.

The list is as follows:'+-define the size of the mail table Number'+-define the corresponding column name N' ID'+ N' name'+ N' used days'+ N' actual used days'+ N' normal status'+-- Table body result CAST ((SELECT td = Empid) ', td = EmpCName,'', td = [ULColA29-AdjAnlUsePos-Sum],'', td = VocaTotalHours,'' Td = [ULColA29-State],''FROM table name Form WHERE filter FOR XML PATH (' tr') TYPE-display the query results in HTML language td/tr) AS NVARCHAR (MAX)) + N'

The above is sent by the system, please do not reply!

Xx department xx 'declare @ i int BEGIN SET @ iTun0 EXEC asdb.dbo.xx_xxx_xxxxx-A functional address that executes SQL mail delivery This address is about to ask the person in charge of the company-- the corresponding email body parameter is brought into the sending email @ profile_name='MIS_SMTP_Mail',-- the email sending name set by the system-- the company mail manager DB setting @ recipients=@MailTo. @ copy_recipients=@MailCc, @ blind_copy_recipients=@MailBcc, @ subject=@MailSubject, @ body=@MailBody @ body_format=@MailFormat SET @ iTunes 1 Is it helpful for ENDEND to read the above content? If you want to know more about the relevant knowledge or read more related articles, please follow the industry information channel, thank you for your support.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report