Home Page for the TeradataForum
 

Archives of the TeradataForum

Message Posted: Tue, 13 Jul 2004 @ 12:22:54 GMT


     
  <Prev Next>   <<First <Prev Next> Last>>  


Subj:   Re: If Exists Then ...Else ....
 
From:   Rob Paller

TeradataForum wrote:

  In MS SQL, you can use IF EXISTS to validate the existance of a table, if it exists you drop it else carry on with code.  


  What is the equivalent in code in Teradata Queryman ?  



I believe it will be a two step process in Teradata

Step 1:

     SEL "DROP TABLE  ' || TRIM(DATABSENAME) || '.' || TRIM(TABLENAME)  || '';'
     FROM DBC.TVM
     WHERE DATABASENAME = 
      AND TABLENAME  IN (,  ,  );

Step 2:

Take the results and execute them.


I am not sure if a Stored Procedure in Teradata would allow the DROP statement to execute. If it does, you can load a cursor with the SQL in STEP 1 then roll through the cursor on statement at a time and execute the drop statements.


--
Rob Paller
Teradata Certified Master



     
  <Prev Next>   <<First <Prev Next> Last>>  
 
 
 
 
 
 
 
 
  
  Top Home Privacy Feedback  
 
 
Copyright for the TeradataForum (TDATA-L), Manta BlueSky    
Copyright 2016 - All Rights Reserved    
Last Modified: 15 Jun 2023