Skip to content

XmlResultFormatter does not work with sqlcmd on Linux #54

Open

Description

@nsturmwind

In order to use the sqlcmd utility to export test results in xml format it is necessary to both use the :XML ON directive and pass the -y0 flag to sqlcmd in order to get the full output. However, the :XML ON directive is not supported in the Linux version of sqlcmd.

As an alternative, casting to nvarchar(max) and using the -y0 flag works, including on Linux. However, tSQLt.XmlResultFormatter does not allow any way to do this cast. It is not possible via INSERT .. EXEC .., since FOR XML cannot be used within INSERT .. EXEC ...

Activity

  1. TheConstructor commented on Oct 24, 2020

    @TheConstructor

    Just out of curiosity: have you tried mssql-cli? I did not yet have the chance to try it.

  2. mbt1 commented on Jan 2, 2022

    @mbt1
    Collaborator

    This could be implemented as an tSQLt.JUnitResultFormatter, as to not change existing behavior.

  3. peterhirn commented on Feb 6, 2023

    @peterhirn

    Workaround for go-sqlcmd

    Windows

    $env:SQLCMDMAXVARTYPEWIDTH=0
    sqlcmd -d test -h-1 -Q "set nocount on; exec tSQLt.XmlResultFormatter" -o results.xml

    Linux

    SQLCMDMAXVARTYPEWIDTH=0 sqlcmd -d test -h-1 -Q "set nocount on; exec tSQLt.XmlResultFormatter" -o results.xml
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions