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
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
0 Comments
if you have any doubts , please let me know