I get the error: Error running SQL script: Exception calling "ExecuteNonQuery" with "0" argument(s): "Could not find stored procedure 'GO'."
This happens because there are two or more "GO" statements back to back. The fix for this is to check to see if the only text is a GO statement in the object. Both commands in the switch statement (lines 54 and 58) can be replaced with:
ForEach-Object { $SqlCmd.CommandText = $_.Trim(); if (!$SqlCmd.CommandText.Equals("GO")) {$reader = $SqlCmd.ExecuteNonQuery()} }
This resolves the issue no matter how many GO statements there are.
I get the error: Error running SQL script: Exception calling "ExecuteNonQuery" with "0" argument(s): "Could not find stored procedure 'GO'."
This happens because there are two or more "GO" statements back to back. The fix for this is to check to see if the only text is a GO statement in the object. Both commands in the switch statement (lines 54 and 58) can be replaced with:
ForEach-Object { $SqlCmd.CommandText = $_.Trim(); if (!$SqlCmd.CommandText.Equals("GO")) {$reader = $SqlCmd.ExecuteNonQuery()} }
This resolves the issue no matter how many GO statements there are.