sqlcmd truncates column width in result file (.rpt)

56 Views Asked by At

I have a sql cmd .bat file that executes a query and returns the query results to a .rpt file (tab delimited). Now in one of the column, not all characters are returned in the .rpt output file.

What I did to try to solve it:

One of the columns in the database contains more than 256 characters, so in SSMS 2018 Options--> query results--> results to text I set the maximum characters displayed in each column to 800 (was 256): still the column width is truncated by sql cmd (manually saving text to file from SSMS does show all characters from that column)

Then I tried to change the sql cmd by adding -y 800, but this results in no output file at all.

So: what command should I add to the sql cmd in order to get all characters from that column into the output file?

Here the original sql cmd I use (that works, but truncates the column):

sqlcmd -S . -E -h -1 -W -i "C:\PathWhereSQLQueryIsLocated\SQLQuery.sql" -s" " -o "C:\PathWereOutputFileIsPlaced\FileName.rpt"

Sqlcmd that I tried, but resulted in no file at all:

sqlcmd -S . -E -h -1 -y 800 -W -i "C:\PathWhereSQLQueryIsLocated\SQLQuery.sql" -s" " -o "C:\PathWereOutputFileIsPlaced\FileName.rpt"

0

There are 0 best solutions below