PS invoke-sql error catching
Posted on 2013-12-26
I'm using invoke-SQL and it is not catching this error and the program cycles through the all of the tables in the database without telling me there was an issue:
"The statement terminated. The maximum recursion 100 has been exhausted before statement completion."
Is there something wrong with this code? I just need the program to stop and tell me if there's an issue.
$ErrorActionPreference = "Stop"
PROGRAM CODE HERE
$CSV = Invoke-Sqlcmd -Query $Query -ErrorAction Stop
$errorout += "major error, query failed problem"
$errorout += $error
MAIN PROGRAM LOOP STARTS HERE