Error handling for batch SQL