Hello,
I have this query which is pulling from a production table:
And this query which is pulling from a temp table:
What is the best way to update the production table with the data from the temp table? The key field (unfortunately) is the field. I was think maybe something with a union all join, or a cascading update, but I'm not sure what the best approach is and how to write it. Any help would be greatly appreciated.
Thank you,
Dennis
I have this query which is pulling from a production table:
Code:
select
o.OrderNumber as [Order Number],
o.CustomerID as [Customer ID],
o.LastName + ' ' + o.FirstName as [Customer Name],
c.Email,
c.AdditionalEmail as [Additional Email],
c.Phone,
o.ShippingCity as [Shipping City],
o.ShippingState as [Shipping State],
o.ShippingZip as [Shipping Zip],
o.ShippingCountry as [Shipping Country],
o.OrderDate as [Order Date],
o.SerialNumbers as [Serial Number],
o.ReorderSerialNumbers as [Reorder Serial Number]
from
orders o WITH (NOLOCK) inner join customer c ON o.CustomerID = c.CustomerID
And this query which is pulling from a temp table:
Code:
select
Number as [Order Number],
OEM_ID as [Customer ID],
DealerName as [Customer Name],
DealerEmail as [Email],
'' as [Additional Email],
DealerPhoneNumber as [Phone],
DealerCity as [Shipping City],
[State] as [Shipping State],
Zip as [Shipping Zip],
'United States' as [Shipping Country],
'2007-12-26' as [Order Date],
'12345' as [Serial Number],
'12346' as [Reorder Serial Number]
from EMPS3_temp
What is the best way to update the production table with the data from the temp table? The key field (unfortunately) is the field. I was think maybe something with a union all join, or a cascading update, but I'm not sure what the best approach is and how to write it. Any help would be greatly appreciated.
Thank you,
Dennis