crimdon / SQLToolkit

An Extension for Azure DevOps Server
MIT License
17 stars 14 forks source link

Error: "Could not find stored procedure 'GO'." #79

Open Jason-De opened 3 years ago

Jason-De commented 3 years ago

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.