开发者

how to store a value returned from a sql query in a variable in batch programming?

开发者 https://www.devze.com 2022-12-27 03:50 出处:网络
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

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

精彩评论

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