Re: Drop if exists
Posted in 1999
From: joel_anderson@prosolution.com
>
>I have a very large script used to modify customer databases. The
>script drops tables, creates tables, and alters tables. The script
>also creates and executes dozens of stored procedures. This script
>runs from dbaccess.
>
>Is there a way in an SQL script to detect if a table, stored procedure,
>index etc. exists before dropping it?
select from systables where tabname = "x";
select from sysindexes where idxname = "x";
select from sysprocedures where procname = "x";
Will tell you whether something exists, but because you can't do any
procedural processing, there's not much you can do with it. The best thing
is to put the DROP object commands in and then run
dbaccess dbname scriptname
on the command line. That will pop up an error message if the object doesn't
exist, but will carry on processing. It's not pretty and it's probably what
you're doing now anyway. :)
HTH.
______________________________________________________
Get Your Private, Free Email at http://www.hotmail.com