SELECT COUNT(*) to html table
I think it is a VERY bad plan to be generating HTML via SQL.  There are many many ways this can go wrong, without even mentioning the maintenance nightmare that this will inevitably cause.

All that being said your solution might be as simple as adding the following:

+ CAST((SELECT COUNT(*) FROM dbo.TABLE_NAME) AS VARCHAR(20)) +


The reason why I think you are having problems is because SQL Server requires you to explicitly convert your integers to strings.