how to create procedure table all data convert in html file using sql

CREATE PROC EMPDATAHTML
AS
BEGIN
DECLARE @Data VARCHAR(MAX),@TableData VARCHAR(MAX),@ResultData VARCHAR(MAX);
SELECT  @Data=CAST((SELECT NAME AS 'td','',AGE AS 'td','',SALARY AS 'td','' FROM EMP FOR XML PATH('tr'),ELEMENTS)AS NVARCHAR(MAX))
--PRINT @Data
SET @TableData ='<html>
<body>
<H2>EMP INFO DATA:</H2>
<hr>
<table bgcolor=orange> 
<tr>
<th>NAME</th><th>AGE</th><th>SALARY</th>
</tr>'   
SET @ResultData = @TableData + @Data +'</table>
</body>
</html>'
--PRINT @ResultData
END

Post a Comment

0 Comments