declare @tablehtml nvarchar(max); set @tablehtml = N'<h1>覈</h1>' + N'<table border="1">' + N'<tr>' + N'<th>table_schema</th>' + N'<th>table_name</th>' + '</tr>' + cast (( select td = table_schema, '' , td = table_name from information_schema.tables for xml path('tr'), type ) as nvarchar(max)) + N'</table>'; select @tablehtml;