I want to update a flag on all records in a table based on the MAX(DateCalc). Seems like I have something wrong. I am not sure if I should be using the WHERE EXISTS. Key to table is ID and DateCalc. Some guidance would be appreciated. Thanks, vmon
UPDATE tblDos_History
SET tblDos_History.Flag_Entry = 'M'
FROM tblDos_History WHERE EXISTS
(SELECT ID, MAX(Date_Calc) AS MaxDateCalc
FROM dbo.tblDOS_History
GROUP BY ID
HAVING MAX(Date_Calc) >= @txtPriorMonthEnd)
UPDATE tblDos_History
SET tblDos_History.Flag_Entry = 'M'
FROM tblDos_History WHERE EXISTS
(SELECT ID, MAX(Date_Calc) AS MaxDateCalc
FROM dbo.tblDOS_History
GROUP BY ID
HAVING MAX(Date_Calc) >= @txtPriorMonthEnd)