I am challenged by the following task.
Here is my question in detail: I need to send email from SQL Server with HTML table format that the email body will have several tables.
Query will be from database like
SELECT Field1, Field2, Field3 FROM Table WHERE DateField >= Somedate
Field3
will be the factor to separate the tables, hence, the result will be grouped byField3
values and put on separate tablesThe email content will be more or less like the following (screenshot is attached)
Section: Field3 Value1 Field Field2 Field3 1 AA Value1 2 BB Value1 3 CC Value1 Section: Field3 Value2 Field Field2 Field3 1 OO Value2 2 XX Value2 3 VV Value2 Section: Field3 Value3 Field Field2 Field3 1 qwqw Value3 2 GGGG Value3 3 COCO Value3
I have tried cursor, however, it will only return only one of the tables (based on the first FETCH value). Any help is appreciated
Using the function I provide here you can do this:
--The query will build this as one big
XHTML
This is the result (click run code snippet to see the result formatted)
Embedd a
<style>
node to add CSS formattingFind further possibilities and background at the link provided above...