Quite easy. You redirect osql to a file, then you read and parse the content of the file with a FOR /F
example (to be encoded in mytest.cmd and to be customized for your environment):
set TEMPFILE=%TEMP%\myprocess%RANDOM%.tmp
osql -S myserver -E -d mydb -Q "SELECT userid, fullname FROM users" > %TEMPFILE%
FOR /F "skip=2 tokens=1,*" %%a IN (%TEMPFILE%) DO (
IF "%%a"=="XYZ" set Fullname=%%b
)
IF EXIST %TEMPFILE% del %TEMPFILE%
Regards
Luc Bolly
Kindest Regards,
Luc Bolly