SQLCMD returns only the first 256 characters of column

Viewed 1815
FOR /f "delims=" %%a IN ('"%SQLCMD%" -E -S %Server% -d %DestDb% -h-1 -i GetResult.sql') do (
  SET Result=%%a
)
ECHO "%Result%"

%Result% is set to the first 256 characters of the actual result.

Is there a way I can get the entire output of the query?

2 Answers

Yes, you can get the full output by using the -y 0 --> 0- unlimited, but beware that this might cause performance issue.

sqlcmd -e -s server_name -Q "your query" -y 0> op_file_path

Note: -h and -y are mutually exclusive

Related