balor
Programmer
- Jul 24, 2000
- 74
Hi,
how do I abort an SQL-script when it contains the GO command?
I want to be able to send the customer a script that creates tables, views and storred procedures etc. and be able to abort the script. At the start of the script I check some stuff and if it's not right I dont want to run the script. I have tried to abort it in many ways but it just keep on going after the next GO.
Example:
IF(EXISTS (SELECT PR_ID FROM PR_Project WHERE PR_Dirty = 1))
BEGIN
--Here I want to abort
END
CREATE PROCEDURE dbo.usp_Test
AS
SELECT Test FROM dbo.Test
GO
CREATE TABLE dbo.TestTable (test int)
GO
INSERT INTO dbo.TestTable (test) VALUES (1)
how do I abort an SQL-script when it contains the GO command?
I want to be able to send the customer a script that creates tables, views and storred procedures etc. and be able to abort the script. At the start of the script I check some stuff and if it's not right I dont want to run the script. I have tried to abort it in many ways but it just keep on going after the next GO.
Example:
IF(EXISTS (SELECT PR_ID FROM PR_Project WHERE PR_Dirty = 1))
BEGIN
--Here I want to abort
END
CREATE PROCEDURE dbo.usp_Test
AS
SELECT Test FROM dbo.Test
GO
CREATE TABLE dbo.TestTable (test int)
GO
INSERT INTO dbo.TestTable (test) VALUES (1)