February 5, 2006 at 11:26 am
Need to fix this malformed update statement but not sure how to fix it.
UPDATE DCR
SET FG_AZ = (SELECT FG_AZ FROM FG fg WHERE fg.CustomerID = DR.Customer),
FG_ty = (SELECT FG_ty FROM FG fg WHERE fg.CustomerID = DR.Customer)
If no match if found in either matches, it should put zero in for the FG_AZ and FG_ty fields
I also tried
February 5, 2006 at 1:44 pm
UPDATE DCR
SET FG_AZ=ISNULL(FG.FG_AZ,0)
,FG_ty = ISNULL(FG.FG_ty,0)
from DCR
LEFT JOIN FG
ON fg.CustomerID = DR.Customer
February 5, 2006 at 1:45 pm
Thanks, the ISNULL worked!!
February 6, 2006 at 12:35 am
If you want to restrict for 0 valued records for Both AZ and FG_ty
UPDATE DCR SET FG_AZ=FG.FG_AZ
,FG_ty = FG.FG_ty
FROM DCR
INNER JOIN FG ON DCR.Customer = FG.CustomerID
WHERE FG.FG_AZ IS NOT NULL AND FG.FG_ty IS NOT NULL
Andy
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply