Home Page for the TeradataForum
 

Archives of the TeradataForum

Message Posted: Tue, 30 Dec 2003 @ 14:46:40 GMT


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


Subj:   Re: Dynamic SQL in Tera data
 
From:   Dempsey, Mike

Another option is to use SQL Assistant.

Switch on Export and issue:

   Select 'Select '
        , ColumnName
        , ', count(*) from YourDB.YourTbl where '
        , ColumnName
        , ' Is NULL Group By 1;'

        From dbc.columns

        where Databasename='YourDB' and TableName='YourTbl'

Load the resulting export file into the query window and remove the first line (This is the title line)

Execute the Query.

If you export the results to a file (and make sure your export options are set to write all results to a single file) you will get a result file with 2 columns - Column name, and count of nulls. It will not be a simple 2 column output but a set of outputs. It is still basically a 2 column file however.

In many cases you would use Import to run the second part but in this case you are substituting a column name (rather than a value) into a Select statement. Import only allows substitution of values in Select,Insert, Update and Delete statements. (Because it uses true parameterized queries in these cases.) For other statements it uses direct substitution so you could replace either a name or a value.

Mike Dempsey
Teradata Client Tools



     
  <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: 23 Jun 2019