开发者

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜