December 9, 2008 at 11:09 am
Suppose I have the following simple statements in a batch script that I execute within either a mgmt studio context or something similar:
select * from tbl
go
if not exists(select * from othertbl)
--need to break out of the script here so the nothing else executes in the file
go
insert into tbl1(fld1)
values(val1)
go
What I need is a way to break out of the script altogether without anything else being executed. The GO statements are autogenerated and cannot be removed so a RETURN statement doesn't work here....
December 12, 2008 at 11:47 am
Why do you have the "go"s in there?
Why not:
select * from tbl
if not exists(select * from othertbl)
insert into tbl1(fld1)
values(val1)
else
select 'done'
December 12, 2008 at 12:06 pm
The script I am using is extremely large (the build script generated by Visual Studio Database Developers Edition) and the go statements need to be in there for items where a CREATE must be the first statement in the execution.
I have a conditional at the very top of the script so that if certain criteria aren't met, it needs to stop executing the .sql script.
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply