Home Page for the TeradataForum
 

Archives of the TeradataForum

Message Posted: Fri, 29 Mar 2013 @ 15:19:38 GMT


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


Subj:   Re: Parameterized column selection
 
From:   de Wet, Johannes M

You may need to use dynamic SQL in a stored Prod if you truly want to make the SQL Column selection dynamic.

Another option might be to use something like the following, if you're OK with hard-coding the CASE Statement below.

     INSERT into table1
     SELECT
        Col1,
        Col2,
        Col3,
        Col4,
        CASE
        WHEN Pilot_Table.Col_Nm = 'Col5' THEN Col5
        WHEN Pilot_Table.Col_Nm = 'Col6' THEN Col6
        WHEN Pilot_Table.Col_Nm = 'Col7' THEN Col7
        WHEN Pilot_Table.Col_Nm = 'Col8' THEN Col8

        ELSE ''
        END AS
     FROM Table2
     CROSS JOIN
         Pilot_table;

Thanks,

Johannes de Wet
Unum



     
  <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