USE AdventureWorks ; GO -- =============================================
-- Author: <qiangguo>
-- Create date: <2009-01-08>
-- Description: <把表中的内容导出为HTML>
-- ============================================= DECLARE@bodyVARCHAR(MAX)
SET@body=CAST(( SELECT td =CAST(ContactID ASVARCHAR(30)) +'</td><td>' + LastName +'</td><td>'+ EmailAddress FROM ( SELECTTOP10
ContactID,
LastName,
EmailAddress FROM Person.Contact
) AS d FOR
XML PATH('tr'),
TYPE
) ASVARCHAR(MAX))