Handle errors similarly to SQLCMD and SSMS
SqlQuantumLeap opened this issue · comments
By default in SQLCMD and SSMS, errors do not abort the current batch or cancel any remaining batches. The following, run in either of those, will return all four result sets:
SELECT 1;
RAISERROR('test 1', 16, 1);
SELECT 2;
GO
SELECT 3;
RAISERROR('test 2', 16, 1);
SELECT 4;
GO
Currently, SimpleSqlExec will abort at the first error. While that behavior is probably preferred, it is different than SQLCMD and SSMS. There should at least be the ability to continue after an error.
Also, emulating SQLCMD behavior requires handling the -b
"batch abort" switch which will terminate at the end of the current batch if there was an error. In the example code above, using -b
should result in getting just the 1 and 2 result sets, not 3 or 4.