Table of Contents

{$page}

Explanation of SQL

This query will set the StationID of part usage cards created from time cards to the StationID of its time card. This is fix for a defect in the earlier versions of Control 4.4 that generated part usage card without properly setting its StationID.

Risk of Data Corruption if Run Improperly

High. Data is modified in this query. Do not run this except under the direction of a Cyrious Technical Support staff member. Doing otherwise may result in lost or contaminated data. All data modifications done through direct SQL are permanent and non-reversable.

SQL

UPDATE PartUsageCard

SET ModifiedByUser = 'Cyrious'

, ModifiedDate = GETDATE()

, PartUsageCard.StationID = TC.StationID

FROM PartUsageCard

LEFT JOIN TimeCard TC ON TC.PartUsageCardID = PartUsageCard.ID

WHERE PartUsageCard.IsFromTimeCard = 1 AND COALESCE(PartUsageCard.StationID,-1) COALESCE(TC.StationID,-1)

Version Information