bigdavelamb
Programmer
Hi, I have a script that I execute, which checks whether a database exists, I wish to then only create the views if this DB exists. I have been attempting to use return, like this:
if not exists(SELECT 1 FROM INFORMATION_SCHEMA.SCHEMATA WHERE CATALOG_NAME='velocity')
return
and i then have my create views after this, but it still executes the rest of the script, ( it seems to be due to the fact I have a GO commands after each view i then try to create, otherwise if I remove the GO's sql says 'CREATE VIEW' must be the first statement in a query batch. Anyone have any ideas?
Thanks,
Dave
if not exists(SELECT 1 FROM INFORMATION_SCHEMA.SCHEMATA WHERE CATALOG_NAME='velocity')
return
and i then have my create views after this, but it still executes the rest of the script, ( it seems to be due to the fact I have a GO commands after each view i then try to create, otherwise if I remove the GO's sql says 'CREATE VIEW' must be the first statement in a query batch. Anyone have any ideas?
Thanks,
Dave