I am using ps script to make a call to db and execute a select statement. The problem is in both the cases where there is some sql error (eg. permission issue) or empty result , there is no way for me tell whether there is a failure or it's just an empty response.
$Result = Invoke-Sqlcmd -ServerInstanc $sqlServer -Database $database -Query $query
So even if there is a permission issue with the db user , the result variable is null and also in case of a empty table, the result variable is null.
How do I differentiate between the two ?