Home Page for the TeradataForum
 

Archives of the TeradataForum

Message Posted: Wed, 09 Mar 2005 @ 22:29:15 GMT


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


Subj:   Re: Record Count Dynamically
 
From:   Muthusamy, Sudha

Hi

You can get the record count dynamically by using the following BTEQ code without using a SP

Let me know if you need more help


Thanks

Sudha


Alter your table and add a column called "num_of_records" and run the following script

     bteq << EOF

     .set session transaction btet;
     .run file=.tdlogon
     .set maxerror 99
     .set width 254

     drop table db.tablecounts ;

     .set maxerror 1

     Create table db.tablecounts
     (tablename     varchar(40), /* tablename with databasename */
     row_count    decimal(18,0))
     Primary index (tablename)
     ;

     .os rm countitnow.lst

     .export report file=countitnow.lst

     select
     'insert into db.tablecounts select '''
     || trim(both from a.tablename)
     ||''', count(*) from '
     ||  trim(both from a.tablename)
     ||';' (title'')
     from   yourtable a ;

     .export reset

     .run file=countitnow.lst

     Update a
     from  yourtable  a ,
           db.Tablecounts b
     Set num_of_records   = b.row_count
     Where a.tablename = b.tablename
     ;

     EOF


     
  <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