Skip to content
Advertisement

SQL Update Only when Max Date reached

I’ve two tables like:

Table1

Table2

The scenario is: If I update the Table2 on TID2 = 2, the LastStatus on Table1 shouldn’t be updated because there’s a MAX Date on Table2 with TID1=1. So LastStatus on Table1 will only updated if there’s an update on Table2 with MAX Date.

Currently, I only work on Table2. It doesn’t effect to Table1. Below are my code:

Does anyone know how to solve this?

Advertisement

Answer

Ideally you would combine the inserts/updates to both tables in a stored procedure where you would do something like the following:

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement