SQL Row Count Script

SQL Row Count Script

I was playing with this script: https://resources.manageengine.com/resources/resource/script-to-execute-sql-query-against-a-local-or-remote-mssql-db-using-sqlcmd-utility

And it properly retrieve a list of rows but now I am trying to figure out how to generate a threshold off of that. Ideally, I would like to run a "Count" using the same logic.

Unfortunately, using "select count (*) From xxxx" is giving me an script error in OpManager even though running the SQLCMD from the OpManager server command line, it properly gets the count. When I use the same query in the script it fails.

Any ideas on why the count isn't working? See attached screenshots.