I\'m trying to set the output of a sqlcmd query to a variable in a batch file.
Here\'s my query:
sqlcmd -S -d -Q \"
Try turning on NOCOUNT:
for /f %%a in ('sqlcmd -S <SERVER> -d <DATABASE> -Q "SET NOCOUNT ON; select max(Column1)+1 from Table1"') do set ColumnVar=%%a echo %ColumnVar% pause