Skip to content

RAISERROR ('Message', 20, 1) WITH LOG causes SQLCMD to hang #785

Description

@alansingfieldcvn

When you execute the following command using a sysadmin account, SQLCMD hangs:

RAISERROR ('Message', 20, 1) WITH LOG

Noted this was mentioned in #76
That issue was closed with only a partial resolution to the issue.

Problem is caused by SQL Server forcibly terminating the connection - go-sqlcmd doesn't realise this has happened so gets into an undefined state and never exits.

https://learn.microsoft.com/en-us/sql/t-sql/language-elements/raiserror-transact-sql?view=sql-server-ver17

"Severity levels from 20 through 25 are considered fatal. If a fatal severity level is encountered, the client connection is terminated after receiving the message, and the error is logged in the error and application logs."

Workaround for me is to set the third parameter of RAISERROR (state) to 127 rather than 1 - but I'd rather it worked the same as ODBC sqlcmd does!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions