|
|
Archives of the TeradataForum
Message Posted: Fri, 29 Mar 2013 @ 15:19:38 GMT
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
| |