1.

Solve : Deploying .sql via batch file?

Answer»

I have written the first part of this that will take in the list I need run and then execute some command. I plan on using the osql or isql depending on which command my work's environment will allow. However I cannot get any database to test on because I have no error handling in it and am unable to delve into the isql or osql commands to see if they have built in error handling. I need to be able to exit the process if an error occurs (which I'm guessing I could do an ErrorLevel==1 if statement and give an exit command). But I need to know if EITHER isql or osql will print the error to a log (id assume the output portion of the command would allow it, but I need to be able to say with 100% certainty to my supervisor).

ThanksQuote from: Grimbear13 on November 16, 2009, 07:33:42 AM

But I need to know if either isql or osql will print the error to a log (id assume the output portion of the command would allow it, but I need to be able to say with 100% certainty to my supervisor).

Thanks
look at the usage of osql or isql in the documentation for more info. yes, there is option output to file. isqlw.exe has the -o param, this writes out to a LOGFILE the messages that would have been printed if you had run it from query analyser -- -oLogFileName.txt
If you are running multiple commands, APPEND the logfile to a master log as it will be overwritten on each execution of isqlwThank You, is my understanding of how ErrorLevel works correct as well? I have never had to use it as I'm just starting with batching and am teaching myself.Ive just checked on my favourite sql site - www.sqlteam.com - a poster there quotes using errorlevel with ISQLW.exe

testing errorlevel can be odd - it returns 0 for ok, anything else means an error - you would test this with
Code: [Select]if errorlevel 1 goto ErrorHandling
this means if errorlevel is 1 OR MORE process the error, it its 0, then it is ok and CONTINUES to the next line


Discussion

No Comment Found