Re: Returning error codes from OSQL
From: RT (rotrived_at_cisco.com)
Date: 09/22/04
- Next message: Kevin Kline: "Re: Replacement for Enterprise Manager?"
- Previous message: Vadim Berman: "ANN: ADDA 1.0.4 released"
- In reply to: Gregory A. Larsen: "Re: Returning error codes from OSQL"
- Messages sorted by: [ date ] [ thread ]
Date: 22 Sep 2004 15:22:01 -0700
This is not what I want to do.
I don't have a single command that I run thru osql. I have a bunch of
commands in an sql script which I'm invoking thru osql. The osql
command is not invoked via a batch file. Instead I call the SQLPrepare
and SQLExecute methods to actually execute the osql command which in
turn runs all the commands in the script file.
Thanks,
Roopa
"Gregory A. Larsen" <greg.larsen@netzero.com> wrote in message news:<#8KmLPCoEHA.1776@TK2MSFTNGP14.phx.gbl>...
> Have you tried something like this. This example set @RC to -100 if table
> XXXX doesn't exist. If XXXX does exist then @RC is equal to 0.
>
> declare @cmd varchar(1000)
> declare @rc int
> set @rc = 0
> set @cmd = 'osql -E -Sdohdbolypr01 -Q"exit(select top 1 * from xxxx)"'
> exec @rc=master.dbo.xp_cmdshell @cmd
> print @rc
>
> --
>
> ----------------------------------------------------------------------------
> ----------------------------------------------------------------------------
> -
>
> Need SQL Server Examples check out my website
> http://www.geocities.com/sqlserverexamples
>
>
> "RT" <rotrived@cisco.com> wrote in message
> news:f9f22d93.0409211255.6492b029@posting.google.com...
> > Hi,
> > I'm using OSQL with the -i option to run an SQL script. I'm also using
> > -o to save the output to a file. I'm invoking this OSQL command via
> > C++ code and would like to get the return code from the SQL script
> > back to the c++ code in case an error condition occurs.
> >
> > OSQL help indicates using RAISERROR with state of 127 to return error
> > codes to the parent process. I've tried that but have not been able to
> > do this successfully. Any examples that anybody may have would be very
> > helpful.
> >
> > There is also the -b option but that only returns 0 or 1.
> > Any help in retrieving the error code from the SQL script back from
> > OSQL would be very much appreciated.
> >
> > Thanks,
> > Roopa
- Next message: Kevin Kline: "Re: Replacement for Enterprise Manager?"
- Previous message: Vadim Berman: "ANN: ADDA 1.0.4 released"
- In reply to: Gregory A. Larsen: "Re: Returning error codes from OSQL"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|