update useby from production plan
-- update useby that do not match production plan useby1 field
begin tran
update dcs_datafile_dates SET dateruledata=pd.useby1
--select plud.DateRuleData, pd.useby1
from dcs_datafile_dates plud
join datafiles_data dd on plud.PLUID=dd.DatafileDataID
join [DGNDWS001].ProductionPlan.dbo.Products PR on dd.Code=convert(varchar(10),pr.plu) and dd.DatafileID=105
join [DGNDWS001].ProductionPlan.dbo.Product_Plant_Details PD ON PR.ProductKey=PD.ProductKey AND PD.PlantKey = 1
where plud.DateID=6
and plud.DateRuleData <> pd.useby1
commit