Drop Table "if exists"

UDA

Drop Table "if exists"

Hi,

I can use the Drop Table "if exists" command in my SQL.
but when I use this command in Teradata I get an error message.

Is there any way I can drop a table only if it already exists in Teradata SQL Assistant 7.1?

Thanks
2 REPLIES

Re: Drop Table "if exists"

I hope we do not have such syntax in teradata SQL.Anyways, teradata automatically errs if the table being dropped does not exists.

for your satisfaction ,using bteq, you can query dbc.tvm table to check the existence of the table.use IF..Then conditional looping as below to drop the table ,if it exists

SELECT......FROM DBC.TVM;
If ACTIVITYCOUNT >0 THEN
DROP TABLE .....;

Teradata Employee

Re: Drop Table "if exists"

You could set ignore and then drop, then reset the level:

.set maxerror 0;

.set errorlevel 3807 severity 0;

drop table foo;

.set errorlevel 3807 severity 8;