Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SQLCMD should exit on certain errors #76

Closed
sommarskog opened this issue Apr 10, 2022 · 1 comment · Fixed by #88
Closed

SQLCMD should exit on certain errors #76

sommarskog opened this issue Apr 10, 2022 · 1 comment · Fixed by #88
Labels
bug Something isn't working

Comments

@sommarskog
Copy link

Consider:

RAISERROR('This is the end', 1, 127)

When you run this in the old SQLCMD, the scripts exits, because state is 127. go-sqlcmd does not. (This an old holdover from ISQL, and should still work I think. No, this does not work in SSMS.)

On a similar note:

RAISERROR('Get me out of here!', 20, 1) WITH LOG

This closes the connection to SQL Server, and old SQLCMD exits at this point. go-sqlcmd does not, but nor does it reconnect, so you only get more error messages.

@shueybubbles shueybubbles added the bug Something isn't working label Apr 12, 2022
@shueybubbles
Copy link
Collaborator

This is gonna be a bit tricky.
Because the severity of this message is <= 10 it is treated as a message instead of an error.
The sqlexp.MsgNotice type only captures the string part of the message, see https://github.com/microsoft/go-mssqldb/blob/39b1cff22838c5a0c85a5e8a196f05e2c462217d/token.go#L815

The go-mssqldb driver would need to extend the sqlexp.MsgNotice type to provide the missing fields.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants