Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Insert into with a union

Author  Topic 

kylenedic
Starting Member

2 Posts

Posted - 2012-07-25 : 16:58:22
I'm trying to insert a unique list of items from two tables using an insert and i retrive the unique list with a union but not sure how to do it
Create table Item_Compare ( ITEM_NUM Varchar2 (30), ORACLE_QUANTITY NUMBER, BPCS_QUANTITY NUMBER);
Insert into Item_Compare (ITEM_NUMBER)
Select ITEM_NUMBER( Select brvc6 FROM APPS.EUL5_B120621201502Q1R1
UNION
SELECT ITEM_NUMBER FROM XXINV.XXINV_ITEM_SNAP_EGS_E5A6)
FROM APPS.EUL5_B120621201502Q1R1, XXINV.XXINV_ITEM_SNAP_EGS_E5A6
WHERE APPS.EUL5_B120621201502Q1R1.brvc12 = ('FG')

Help is apperciated!

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-07-25 : 17:00:51
simply this would do


Insert into Item_Compare (ITEM_NUMBER)
Select brvc6
FROM APPS.EUL5_B120621201502Q1R1
WHERE brvc12 = 'FG'

UNION

SELECT ITEM_NUMBER
FROM XXINV.XXINV_ITEM_SNAP_EGS_E5A6


------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -