Toad World® Forums

Toad, Teradata, SQL Union of two tables


#1

Hi, I have two tables, they were origianlly the same table but I pulled out a subset, added two new columns, so the first table has two additional columns that the second table did not have, column10 VARCHAR(50); & column11 SMALLINT; both columns are at the end of the table.

I added these two columns to the second table knowing that in order to union they must be similar and they both appear at the end of the table in the same order as well.

But I am still getting “Corresponding select - list expressions are incompatable” I tried to set to NOT NULL but made no difference.

Here is what script looks like.

ALTER TABLE ar_asrh_dm_etl_beacon.Flg_ER_Algo1a3
ADD MSDrg_ds VARCHAR(50);

UPDATE ar_asrh_dm_etl_beacon.Flg_ER_Algo1a3

SET MSDrg_ds = ‘’;

ALTER TABLE ar_asrh_dm_etl_beacon.Flg_ER_Algo1a3
ADD MS_IF_A_id SMALLINT;

UPDATE ar_asrh_dm_etl_beacon.Flg_ER_Algo1a3

SET MS_IF_A_id = ‘’;

CREATE TABLE ar_asrh_dm_etl_beacon.Flg_ER_Algo1a5 as
(SELECT * FROM ar_asrh_dm_etl_beacon.Flg_ER_Algo1a3 a3
UNION ALL
SELECT * FROM ar_asrh_dm_etl_beacon.Flg_ER_Algo1a4 a4)

WITH DATA;

Would appreciate any insight into what I am doing wrong, thank you.

WHP


#2

Could you provide the DDL for these tables?