TSQL — Sending Email in HTML Table Format in SQL Server

Ryan Arjun
6 min readApr 25, 2024

As we know that SQL language is specified as an ANSI and ISO standard and performance, scalability, and optimisation are important for database-driven applications, especially on the Web.

In application development, we are required to build a SQL program to perform certain task(s) on periodic basis or daily basis. For example — send an email alert with Department Wise Employee List from SQL Server to business users. Let us discuss how we can send an email in HTML table format using TSQL.

Database mail is the most useful feature of SQL Server which allows us to send email though the database. This feature can be used in reporting services, integration services and in our application also.

By using this feature, we can easily tracks the email logs also and schedule these email alerts by the help of SQL Server Agent.

It is important to us before sending emails from SQL Server, we should have the following things-

1) Email Profile

2) An activated and authorised email account

3) Enabling and configuring Database Mail in SQL Server

To know all the above steps and their configuration, you can visit Enabling and configuring Database Mail in SQL Server using T-SQL

--

--

Ryan Arjun

BI Specialist || Azure || AWS || GCP — SQL|Python|PySpark — Talend, Alteryx, SSIS — PowerBI, Tableau, SSRS