Home Page for the TeradataForum
 

Archives of the TeradataForum

Message Posted: Tue, 18 Jul 2006 @ 12:31:55 GMT


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


Subj:   Re: How to find the table list for particular value of a column in a Database.
 
From:   Vinod Sugur

Hi,

The query written below is two step query:

a. First step is to execute the below query with replacement for columnvalue and columnname (i.e 20 and column_1)

     Select CASE
     WHEN Row_Number() OVER(Order by 1)  = 1 THEN
     'SELECT '''||rtrim(databasename)|| '.'
     ||rtrim(tablename)||'.'||rtrim(columnname)||''',' || columnname || '
     FROM '
     || rtrim(databasename) || '.' || tablename || ' WHERE '  ||
     rtrim(columnname) || ' =' || '20'
     ELSE
     'UNION SELECT '''||rtrim(databasename)|| '.'
     ||rtrim(tablename)||'.'||rtrim(columnname)||''',' || columnname || '
     FROM '
     || rtrim(databasename) || '.' || tablename || ' WHERE '  ||
     rtrim(columnname) || ' =' || '20'
     END
     FROM dbc.columns
     Where columnname='column_1';

b. The result of the first query needs to be execute to obtain the desired result.


Regards,

Vinod Sugur



     
  <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