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

Posted by Arunachalam on Stack Overflow See other posts from Stack Overflow or by Arunachalam
Published on 2010-04-15T09:07:46Z Indexed on 2010/04/15 9:13 UTC
Read the original article Hit count: 223

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 with numeric values in if condition

© Stack Overflow or respective owner

Related posts about scripting

Related posts about command-prompt