SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


How to import sql data in HTML table


How to import sql data in HTML table

Author
Message
avdhut.k
avdhut.k
SSChasing Mays
SSChasing Mays (659 reputation)SSChasing Mays (659 reputation)SSChasing Mays (659 reputation)SSChasing Mays (659 reputation)SSChasing Mays (659 reputation)SSChasing Mays (659 reputation)SSChasing Mays (659 reputation)SSChasing Mays (659 reputation)

Group: General Forum Members
Points: 659 Visits: 266
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!!
Sean Pearce
Sean Pearce
SSCarpal Tunnel
SSCarpal Tunnel (4.2K reputation)SSCarpal Tunnel (4.2K reputation)SSCarpal Tunnel (4.2K reputation)SSCarpal Tunnel (4.2K reputation)SSCarpal Tunnel (4.2K reputation)SSCarpal Tunnel (4.2K reputation)SSCarpal Tunnel (4.2K reputation)SSCarpal Tunnel (4.2K reputation)

Group: General Forum Members
Points: 4170 Visits: 3436
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
avdhut.k
avdhut.k
SSChasing Mays
SSChasing Mays (659 reputation)SSChasing Mays (659 reputation)SSChasing Mays (659 reputation)SSChasing Mays (659 reputation)SSChasing Mays (659 reputation)SSChasing Mays (659 reputation)SSChasing Mays (659 reputation)SSChasing Mays (659 reputation)

Group: General Forum Members
Points: 659 Visits: 266
Thanks a lot!!
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search