Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Capture output of sqlcmd before shutdown services

Author  Topic 

TRACEYSQL
Aged Yak Warrior

594 Posts

Posted - 2013-12-07 : 22:17:37
I have a bat file, which I run the statement sqlcmd -S Sqlservername -E -Q "select STATUS from MYDATABASE.DBO.CONTROLLOG" -o d:\scripts\testoutput1.txt -e

Once captured the output
if the status is COMPLETE, then I can restart some application services.

How do I capture the status in a variable so I can do
----The start part works, I have this in a bat file too
IF @STATUS = 'COMPLETE'
SC \\SERVER START "MY APPLICATION"
END
   

- Advertisement -