English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

I'm creating views and stored procedures in my database via a script. If a certain table does not exist, I don't want to create some of the objects, so I want to exit the script at that point, or put a condition if/then loop around that part of the script.

2006-09-26 06:37:22 · 3 answers · asked by colo programmer 1 in Computers & Internet Programming & Design

Quit doesn't work, and I've tried EXIT, but get an error.

2006-09-28 07:58:58 · update #1

I did the if exists thing, but there are many objects I want to create if a certain table exists. I tried a begin end loop, but got an error with that, too. if exist (anntab)
begin create view1 go create view2 go create storedproc1 go end
gives me errors.

2006-09-28 11:32:27 · update #2

3 answers

The command is EXIT or QUIT

2006-09-26 06:41:09 · answer #1 · answered by Chuck C 3 · 0 0

it truly is not any longer genuine clean. There are different styles of scripts which will be utilized in a sq. Server surroundings. i'd imagine sq. scripting may be what they are which ability although.

2016-12-02 02:42:57 · answer #2 · answered by rezendes 3 · 0 0

if exists (select * from sysobjects where name = 'MyObject')
--add your create script here

GO

so long as the conditions are met in the if statement, the next statement will execute.

2006-09-28 09:48:40 · answer #3 · answered by © 2007. Sammy Z. 6 · 0 0

fedest.com, questions and answers