Reputation: 6415
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?
Upvotes: 6
Views: 4262
Reputation: 21
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
Upvotes: 1
Reputation: 6415
SQLCMD limits variable length columns to 256 by default. The -y 0 parameter fixed this.
FOR /f "delims=" %%a IN ('"%SQLCMD%" -E -S %Server% -d %DestDb% -y 0 -i GetResult.sql') do (
SET Result=%%a
)
ECHO "%Result%"
-h and -y parameters are mutually exclusive, so -h-1 had to be removed.
Upvotes: 10