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
 SQL Server 2000 Forums
 SQL Server Administration (2000)
 OSQL - can the error

Author  Topic 

ulustig
Starting Member

1 Post

Posted - 2005-03-06 : 07:28:01
Hi,

I am using OSQL in a batch file to create a database/user/tables and need a way to fint out if there was an error or not, how can I do that ?

TG
Master Smack Fu Yak Hacker

6065 Posts

Posted - 2005-03-06 : 08:16:18
You can redirect the output to a file using the -o switch. (-n suppresses the numbers that osql generates in the output.)

ie:
osql -S myServer -U myLogin -P myPassword -d myDatabase -i c:\osqltest.sql -o c:\osqltest.txt -n

Be One with the Optimizer
TG
Go to Top of Page

TimS
Posting Yak Master

198 Posts

Posted - 2005-03-07 : 14:01:35
osql.exe blah blah
IF errorlevel 1 goto error

SEE EXIT() function also.

Tim S
Go to Top of Page
   

- Advertisement -