There was another question for you. I do the trigger. There are two columns with dates, first I want to calculate with the help of a trigger the difference in days between these dates, and then from 30 to subtract the resulting number ...
The difference is considered normal, and with the second part there is a problem: it does not work correctly. What do you tell me, here is the code:
CREATE TRIGGER TR1 ON Table1 FOR INSERT,UPDATE AS UPDATE Table1 set KolvoDays=DATEDIFF(DAY,StartDate,FinishedDate) UPDATE Table1 set Ostatok=30-(select KolvoDays from inserted where inserted.NumID=NumID)