Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

How to import sql data in HTML table Expand / Collapse
Author
Message
Posted Friday, October 11, 2013 6:56 AM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Friday, July 25, 2014 12:01 AM
Points: 132, Visits: 254
Hi,
I am Using HTML format for body for sending DBmail.

Now my requirement is I want display a table in a mail body.with some that sholud be come from sql table.


Please help me!

Thanks in advance!!
Post #1503985
Posted Friday, October 11, 2013 7:22 AM


SSC Eights!

SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!

Group: General Forum Members
Last Login: Today @ 1:38 AM
Points: 826, Visits: 2,661
This should get you on the right track

DECLARE @Body NVARCHAR(MAX);

SET @Body = N'<HTML><BODY><TABLE BORDER="1">' + CAST((
SELECT
(SELECT name AS 'TD' FOR XML PATH(''), TYPE),
(SELECT object_id AS 'TD' FOR XML PATH(''), TYPE),
(SELECT SCHEMA_NAME(schema_id) AS 'TD' FOR XML PATH(''), TYPE)
FROM
sys.tables t
FOR XML RAW('TR'), ELEMENTS
) AS NVARCHAR(MAX));

SET @Body = @Body + '</TABLE></HTML>';





The SQL Guy @ blogspot

@SeanPearceSQL

About Me
Post #1503999
Posted Monday, October 14, 2013 1:04 AM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Friday, July 25, 2014 12:01 AM
Points: 132, Visits: 254
Thanks a lot!!
Post #1504335
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse