Re: Stop execution of script

From: x-rays (xrays_at_discussions.microsoft.com)
Date: 11/12/04


Date: Fri, 12 Nov 2004 01:52:03 -0800

Thanks responding Jacco,
Yes I could that, but because the script will run through an upgrade process
(using setup of wise) it might stack the hole thing. Maybe I can capture it,
I'll try it in the next days.
Maybe I can Use the WHILE..BREAK, I'll test it and let you know.

Thanks in advance

"Jacco Schalkwijk" wrote:

> The label must be in the same batch as the GOTO, i.e. they can not be
> separated by a GO.
>
> If you use osql to run a script, you can exit it by raising an error with
> status 127:
>
> RAISERROR('Exiting now', 16, 127)
>
> If you run it in Query Analyzer, that won't work, but you can still abort
> execution (and terminate the connection) by raising an error with severity
> 20 or higher. You need to be a member of the sysadmin role to do this:
>
> RAISERROR('Exiting now', 20,1)
>
> --
> Jacco Schalkwijk
> SQL Server MVP
>
>
> "x-rays" <xrays@discussions.microsoft.com> wrote in message
> news:8CC09CCE-DD61-402D-BA19-3D0EBE4D6A24@microsoft.com...
> > Thanks responding Uri,
> > I tried that too but because of separate batch executions
> > the error that raises is:
> > A GOTO statement references the label 'EXIT' but the label has not been
> > declared.
> >
> > "Uri Dimant" wrote:
> >
> >> x-rays
> >> Perhaps you want to try GOTO.
> >>
> >> If 'a' <> 'b'
> >> begin
> >> print 'not equal'
> >> GOTO exit
> >> end
> >>
> >> exit:
> >> RETURN
> >>
> >>
> >>
> >> "x-rays" <xrays@discussions.microsoft.com> wrote in message
> >> news:94E9AB19-9C21-4DF9-A23B-2823A5B341DC@microsoft.com...
> >> > hello Experts,
> >> >
> >> > this question might be a dump one but i will ask it anyway.
> >> >
> >> > I run a script like the following:
> >> >
> >> > If 'a' <> 'b'
> >> > begin
> >> > print 'not equal'
> >> > return
> >> > end
> >> >
> >> > if object_id('MyStoredProcedure') Is not null
> >> > drop procedure MyStoredProcedure
> >> > GO
> >> >
> >> > CREATE Procedure MyStoredProcedure
> >> >
> >> > AS
> >> > set nocount on
> >> > select 'something'
> >> > set nocount off
> >> > GO
> >> >
> >> > So because a and b is not obviously equal I need the script to stop,
> >> > but
> >> > because of GOs (separates executions) script will continue. Is there
> >> > any
> >> way
> >> > to stop it at the point I want without using dynamic sql?
> >> >
> >> > Thanks in advance!
> >>
> >>
> >>
>
>
>



Relevant Pages

  • Re: Option Explicit and MSScriptControl.ScriptControl
    ... I tried that but the ScriptControl is not raising any errors for the below ... Option Explicit ... script written without having to run anything, ... stray text that the control is not raising an error for. ...
    (microsoft.public.vb.general.discussion)
  • Re: Simple question
    ... but from the script file you call other script files with:r. ... (-n -h-1 is to limit the amount of garbage osql produce) ... Both sql scripts will now be run. ... > "Jacco Schalkwijk" ...
    (microsoft.public.sqlserver.programming)
  • Re: Query Analyser - how do i terminate a script
    ... Or, if you run the script from OSQL or ISQL, you can do a raiserror with a *state* of 127. ... Tibor Karaszi, SQL Server MVP ... "Jacco Schalkwijk" wrote in message ... > the connection with SQL Server for that Query window. ...
    (microsoft.public.sqlserver.tools)
  • Clay Liston I
    ... Cassius was raising his hands 5-6 seconds prematurely ... because he knew the script, not because he could see what ... His family should take better care of him. ...
    (rec.sport.boxing)
  • Archiving the OLAP Database
    ... i am trying to backup the olap database from a script i wrote but the sql ... server is raising a error ... 'msmdarch' is not recognized as an internal or external command, ...
    (microsoft.public.sqlserver.olap)

Loading