October 12, 2023 at 3:45 pm
Hi all,
This is what I need to do. I need to get a field called chargeguid from the charge table of my destination database but the problem I have is, I am copying the data from my source table, the source table has the chargeID in it so I need to join my destination chargebreaks table to the destination charge table to get the GUID but I also need to join it to the source chargebreaks table to get the charge ID because the destination table only has the chargeguid field in it, not charge ID, so the source chargebreaks table must also be joined to the destination charge table so I can use the source.chargebreaks.chargeid to get the destination.chargebreaks.chargeguid. I cannot join the destination.chargebreaks table to the source.chargebreaks table because the PK field in the source.chargebreaks table is GUID and the PK field in the destination.chargebreaks table is ChargeBreaksID. Does that make sense? It's frying my brain! I tried it like this but I get the subquery returned more than 1 value error. Thanks in advance.
update conversion.dbo.chargebreaks set chargeguid = (select chargeguid from conversion.dbo.charge as dest
inner join speedlink.dbo.chargebreaks as source on dest.chargeid = source.chargeid
where source.chargeid = dest.chargeid)
October 12, 2023 at 4:12 pm
I think I've got it now....
update Conversion.dbo.chargebreaks
set chargeguid = dest.chargeguid
from conversion.dbo.charge as dest inner join
speedlink.dbo.chargebreaks as source on
dest.chargeid = source.chargeid
Viewing 2 posts - 1 through 1 (of 1 total)
You must be logged in to reply to this topic. Login to reply