how to store a value returned from a sql query in a variable in batch programming?
how to store a value returned from a sql query in a variable in batch programming ?
i can invoke sqlserver queries from my cmd prompt using sqlcmd server name then the qwery
this is query statement i m going to use
SELECT CASE WHEN DATEDIFF(minute, record_timestamp, GETDATE()) < 10 THEN 1 ELSE 0 END
how to store the value returned
i tried using set variablename but it save the statement rather than the return value ..
and if i save this in a variable what type of variable it will can i compare it wi开发者_Python百科th numeric values in if condition
you use the cmd.exe's for loop. eg
for /F "tokens= delims=" %%a in ('sqlcmd....') do(
set returned=%%a
)
tokens and delims are up to you to define.
加载中,请稍侯......
精彩评论