Home / Microsoft / Microsoft DOS / Deploying .sql via batch file
0 Members and 1 Guest are viewing this topic. « previous next »
Pages: [1] - (Bottom) Print
Author Topic: Deploying .sql via batch file  (Read 548 times)
Grimbear13
Topic Starter
Rookie



Posts: 43


« on: November 16, 2009, 07:33:42 AM »

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).

Thanks
IP logged
gh0std0g74
Apprentice



Thanked: 37
Posts: 590


« Reply #1 on: November 16, 2009, 08:53:03 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.
IP logged

gpl
Apprentice



Thanked: 25
Posts: 546




« Reply #2 on: November 16, 2009, 09:11:59 AM »

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 isqlw
IP logged
Grimbear13
Topic Starter
Rookie



Posts: 43


« Reply #3 on: November 16, 2009, 09:31:32 AM »

Thank 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.
IP logged
gpl
Apprentice



Thanked: 25
Posts: 546




« Reply #4 on: November 16, 2009, 10:11:24 AM »

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
IP logged
Pages: [1] - (Top) Print 
Home / Microsoft / Microsoft DOS / Deploying .sql via batch file « previous next »
 


Login with username, password and session length

Old Forum Search | Forum Rules
Copyright © 2010 Computer Hope ® All rights reserved.
Powered by SMF 2.0 RC3 | SMF © 2006–2010, Simple Machines LLC
Page created in 0.091 seconds with 20 queries.