If I'm using sqlcmd in a batch script, can I reference a batch variable inside the query?
So that if I do something like
for /f "delims= " %%a in ('sqlcmd -S SERVER -d DATABASE -Q
"SELECT Column1 FROM Table1 WHERE Column1=[specific number]"') do set var1=%%a
how could I do something like this?:
for /f "delims= " %%b in ('sqlcmd -S SERVER -d DATABASE -Q
"SELECT Column2 FROM Table1 WHERE Column2=[var1]"' do set var2=%%b
So that the WHERE condition in the second sqlcmd statement is using the variable set in the first statement?