Skip to content

XmlResultFormatter does not work with sqlcmd on Linux #54

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

Open
nsturmwind opened this issue Jan 3, 2020 · 3 comments
Open

XmlResultFormatter does not work with sqlcmd on Linux #54

nsturmwind opened this issue Jan 3, 2020 · 3 comments

Comments

@nsturmwind
Copy link

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 ...

@TheConstructor
Copy link

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

@mbt1
Copy link
Collaborator

mbt1 commented Jan 2, 2022

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

@peterhirn
Copy link

peterhirn commented Feb 6, 2023

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
Projects
None yet
Development

No branches or pull requests

4 participants