I'm getting an error on the line that has the "case" statement. The error is:
Invalid column name 'ProductTransactionStatusCode'.
I have confirmed that the column name, which is of VARCHAR type, is in fact in the table ProductInformation_W
The SQL 2008 statement is:
UPDATE
ProductInformation
SET
ProductInformation.CollectionDate = h.CollectionDate
,ProductInformation.ExpirationDate = CONVERT(DATETIME, LEFT(CONVERT(VARCHAR, h.ExpirationDate, 120), 10) + ' ' + h.ExpirationTime + ':00.000', 121)
,ProductInformation.CreationDate = h.CreationDate
,ProductInformation.CollectionLocationCode = h.CollectionLocationCode
,ProductInformation.ProductTypeCode = h.ProductTypeCode
,ProductInformation.ProductStatusCode = h.ProductStatusCode
,ProductInformation.InventoryClassCode = h.InventoryClassCode
,ProductInformation.StockStateCode = h.StockStateCode
,ProductInformation.Imported = h.Imported
,ProductInformation.Exported = (Case When h.ProductTransactionStatusCode In ('048', '051') Then h.Exported Else p.ProductTransactionStatusCode End)
,ProductInformation.ProcessingLocationCode = h.ProcessingLocationCode
,ProductInformation.RunDateTime = getdate()
FROM
ProductInformation p
INNER JOIN
ProductInformation_W h
ON
p.UnitNumber = h.UnitNumber AND p.ProductCode = h.ProductCode AND p.Suffix = h.Suffix