Showing posts with label executes. Show all posts
Showing posts with label executes. Show all posts

Sunday, February 19, 2012

how to stop executing a script

a setup process executes a script via osql. I want to parameterize
it in such a way that whenever wanted the script will do nothing.
For that I plan to created a table in master database, say
NODROP_DATABASE
the first few lines of the script will be
IF EXISTS (SELECT * FROM master.dbo.sysobjects where name =
'NODROP_DATABASE'
and type = 'U')
BEGIN
return
END
-- rest of the script here with many GO in between.
what is happening is that the return statement takes the control to the
first line after GO. The execution continues from the first GO after
that.
Is there any other approach to stop executing.
Assuming the script is run by a SYSADMIN you can RAISERROR with a severity
of 20 or greater to terminate the current connection.
Alternatively, run the script from OSQL with the -b option and it will
terminate on the first error.
David Portas
SQL Server MVP
|||... or, if using OSQL, issue a RAISERROR with state 127. OSQL will stop on errors with state 127.
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
Blog: http://solidqualitylearning.com/blogs/tibor/
"David Portas" <REMOVE_BEFORE_REPLYING_dportas@.acm.org> wrote in message
news:peKdnWO5478MiE3fRVn-vw@.giganews.com...
> Assuming the script is run by a SYSADMIN you can RAISERROR with a severity of 20 or greater to
> terminate the current connection.
> Alternatively, run the script from OSQL with the -b option and it will terminate on the first
> error.
> --
> David Portas
> SQL Server MVP
> --
>
|||Tibor Karaszi wrote:

> ... or, if using OSQL, issue a RAISERROR with state 127. OSQL will stop on errors with state 127.
David and Tibor,
Raising error with RAISEERROR means abnormal termination. The problem
with
that approach is that setup has to be programmed to ignore 127. I want
a graceful exit from running the script as if the script ran
successfully.
|||Why not just add the conditional test in your calling code and decide
at that point whether or not to execute the script. I can't think of a
better way.
David Portas
SQL Server MVP
|||Hi,
You could try to use labels.
IF (1 = 1)
GOTO QUIT
PRINT 'Not executing code'
QUIT:
PRINT 'Quit'
Ramon @. Havana Club,
SQL Server MCDBBA
"Data Cruncher" <dcruncher4@.netscape.net> ??/?? ? ??
??: news:1121093312.487489.156320@.z14g2000cwz.googlegr oups.com...[vbcol=seagreen]
> Tibor Karaszi wrote:
on errors with state 127.
> David and Tibor,
> Raising error with RAISEERROR means abnormal termination. The problem
> with
> that approach is that setup has to be programmed to ignore 127. I want
> a graceful exit from running the script as if the script ran
> successfully.
>

how to stop executing a script

a setup process executes a script via osql. I want to parameterize
it in such a way that whenever wanted the script will do nothing.
For that I plan to created a table in master database, say
NODROP_DATABASE
the first few lines of the script will be
IF EXISTS (SELECT * FROM master.dbo.sysobjects where name =
'NODROP_DATABASE'
and type = 'U')
BEGIN
return
END
-- rest of the script here with many GO in between.
what is happening is that the return statement takes the control to the
first line after GO. The execution continues from the first GO after
that.
Is there any other approach to stop executing.Assuming the script is run by a SYSADMIN you can RAISERROR with a severity
of 20 or greater to terminate the current connection.
Alternatively, run the script from OSQL with the -b option and it will
terminate on the first error.
David Portas
SQL Server MVP
--|||... or, if using OSQL, issue a RAISERROR with state 127. OSQL will stop on
errors with state 127.
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
Blog: http://solidqualitylearning.com/blogs/tibor/
"David Portas" <REMOVE_BEFORE_REPLYING_dportas@.acm.org> wrote in message
news:peKdnWO5478MiE3fRVn-vw@.giganews.com...
> Assuming the script is run by a SYSADMIN you can RAISERROR with a severity
of 20 or greater to
> terminate the current connection.
> Alternatively, run the script from OSQL with the -b option and it will ter
minate on the first
> error.
> --
> David Portas
> SQL Server MVP
> --
>|||Tibor Karaszi wrote:

> ... or, if using OSQL, issue a RAISERROR with state 127. OSQL will stop on errors
with state 127.
David and Tibor,
Raising error with RAISEERROR means abnormal termination. The problem
with
that approach is that setup has to be programmed to ignore 127. I want
a graceful exit from running the script as if the script ran
successfully.|||Why not just add the conditional test in your calling code and decide
at that point whether or not to execute the script. I can't think of a
better way.
David Portas
SQL Server MVP
--|||Hi,
You could try to use labels.
IF (1 = 1)
GOTO QUIT
PRINT 'Not executing code'
QUIT:
PRINT 'Quit'
Ramon @. Havana Club,
SQL Server MCDBBA
"Data Cruncher" <dcruncher4@.netscape.net> '?/'' ? ''
'?: news:1121093312.487489.156320@.z14g2000cwz.googlegroups.com...
> Tibor Karaszi wrote:
>
on errors with state 127.[vbcol=seagreen]
> David and Tibor,
> Raising error with RAISEERROR means abnormal termination. The problem
> with
> that approach is that setup has to be programmed to ignore 127. I want
> a graceful exit from running the script as if the script ran
> successfully.
>

how to stop executing a script

a setup process executes a script via osql. I want to parameterize
it in such a way that whenever wanted the script will do nothing.
For that I plan to created a table in master database, say
NODROP_DATABASE
the first few lines of the script will be
IF EXISTS (SELECT * FROM master.dbo.sysobjects where name = 'NODROP_DATABASE'
and type = 'U')
BEGIN
return
END
-- rest of the script here with many GO in between.
what is happening is that the return statement takes the control to the
first line after GO. The execution continues from the first GO after
that.
Is there any other approach to stop executing.Assuming the script is run by a SYSADMIN you can RAISERROR with a severity
of 20 or greater to terminate the current connection.
Alternatively, run the script from OSQL with the -b option and it will
terminate on the first error.
--
David Portas
SQL Server MVP
--|||... or, if using OSQL, issue a RAISERROR with state 127. OSQL will stop on errors with state 127.
--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
Blog: http://solidqualitylearning.com/blogs/tibor/
"David Portas" <REMOVE_BEFORE_REPLYING_dportas@.acm.org> wrote in message
news:peKdnWO5478MiE3fRVn-vw@.giganews.com...
> Assuming the script is run by a SYSADMIN you can RAISERROR with a severity of 20 or greater to
> terminate the current connection.
> Alternatively, run the script from OSQL with the -b option and it will terminate on the first
> error.
> --
> David Portas
> SQL Server MVP
> --
>|||Tibor Karaszi wrote:
> ... or, if using OSQL, issue a RAISERROR with state 127. OSQL will stop on errors with state 127.
David and Tibor,
Raising error with RAISEERROR means abnormal termination. The problem
with
that approach is that setup has to be programmed to ignore 127. I want
a graceful exit from running the script as if the script ran
successfully.|||Why not just add the conditional test in your calling code and decide
at that point whether or not to execute the script. I can't think of a
better way.
--
David Portas
SQL Server MVP
--|||Hi,
You could try to use labels.
IF (1 = 1)
GOTO QUIT
PRINT 'Not executing code'
QUIT:
PRINT 'Quit'
Ramon @. Havana Club,
SQL Server MCDBBA
"Data Cruncher" <dcruncher4@.netscape.net> '?/'' ? ''
'?: news:1121093312.487489.156320@.z14g2000cwz.googlegroups.com...
> Tibor Karaszi wrote:
> > ... or, if using OSQL, issue a RAISERROR with state 127. OSQL will stop
on errors with state 127.
> David and Tibor,
> Raising error with RAISEERROR means abnormal termination. The problem
> with
> that approach is that setup has to be programmed to ignore 127. I want
> a graceful exit from running the script as if the script ran
> successfully.
>

How to stop automatic excution of a report?

Hi,

I have a report containing one multi-value parameter with default values given. When open I report in Report Manager, report executes automatically. I need to stop this automatic execution of report. I need to give user an option to check if default values are ok for him or not. Is there any way other than removing default value from parameter to do this?

Thanks in anticipation.

Saeed

Sorry, there is no way to achieve this behavior in Report Manager. You need to remove the default value, otherwise the report will render.|||

It is unfortunate that this was not considered as a requirement during development. However, you can work around this by adding an additional report parameter. Add a Start Report parameter as a string with 1 non-queried availabIe value like 'Yes'. The report will not render until the user selects the only available option for that parameter. Its not the best solution but is a viable workaround to the default rendering problem.

|||Hi
Rather than use default parameters in a report why dont you make the report show a list of valid values e.g. from a query and the user will sellect appropriate value.
e.g.

A report uses a paramater param1; create a dataset with a sql query that generates valid values and make your report parameter populate from this dataset. You can set the default value to null so that the report prompts for the parameters from the valid list.

How to stop automatic excution of a report?

Hi,

I have a report containing one multi-value parameter with default values given. When open I report in Report Manager, report executes automatically. I need to stop this automatic execution of report. I need to give user an option to check if default values are ok for him or not. Is there any way other than removing default value from parameter to do this?

Thanks in anticipation.

Saeed

Sorry, there is no way to achieve this behavior in Report Manager. You need to remove the default value, otherwise the report will render.|||

It is unfortunate that this was not considered as a requirement during development. However, you can work around this by adding an additional report parameter. Add a Start Report parameter as a string with 1 non-queried availabIe value like 'Yes'. The report will not render until the user selects the only available option for that parameter. Its not the best solution but is a viable workaround to the default rendering problem.

|||Hi
Rather than use default parameters in a report why dont you make the report show a list of valid values e.g. from a query and the user will sellect appropriate value.
e.g.

A report uses a paramater param1; create a dataset with a sql query that generates valid values and make your report parameter populate from this dataset. You can set the default value to null so that the report prompts for the parameters from the valid list.