This may be a very simple but it's still not clear to me. I'm writing a SQL Agent job to generate output in html format.
I need to get results of a query
SELECT COUNT(*) FROM TABLE_NAME. I'm able to get output generated with actual data in html but I just need count from table.
What is the easiest way to do it?
Here is part of my query:
SET @tableHTML = N'<table border="1">' + N'<FONT SIZE="3" FACE="Calibri">' + N'<tr><th align="center">COLUMN_NAME</th>' + N'</tr>' + ISNULL(CAST ( ( SELECT td = [COLUMN_NAME],'' FROM dbo..TABLE_NAME FOR XML PATH('tr'), TYPE ) AS NVARCHAR(MAX) ),'') + N'</FONT>' + N'</table>'
Can someone please help me to get output as count instead of individual row in output.
I have couple staging tables for a process and need to get notification for those tables with data in it. First table I only need row count. There is only one column in it. And second table has 4 Columns and I got expected output for it in sql job. Actually I just need to add one line with total rows from table to output in mail. I hope this will help to understand the question better.
It doesn't need to be in HTML but my second table needs to be included in output makes it easy to generate proper table output. I'm not much familiar with sql stuff yet. Still learning.