Click here to Skip to main content
15,885,546 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more: , +
Change status automatically using trigger from database when system date and date(from database) are equal

My table is-:

Employee

Id Status Date
1 false 2015-06-25
2 false 2015-06-25
3 false 2015-06-26
4 false 2015-06-26

If system date will be '2015-06-25' then using trigger status of Id:1 and 2 will be true and if system date will be '2015-06-26' then it will change the status false to true.
Posted
Updated 25-Jun-15 2:09am
v2
Comments
John C Rayan 25-Jun-15 7:41am    
Can you explain it more clearer? What do you want to do? Do you want to update the status column using a trigger when the system date and date in the row matches?
Abhishek Burrnwal 25-Jun-15 7:47am    
when system date change after that check Date value match the system date then status value to automatically change.
John C Rayan 25-Jun-15 8:15am    
Right! The trigger will only work for some events like INSERT , UPDATE or DELETE etc. For your requirements you may have to run a job in the SQL server daily to check the system date and any match in the rows then update the status.
TenmanS14 25-Jun-15 9:11am    
yup, and if your using express edition then you can do it with scheduled tasks, batch files and the sqlcmd command, prob. run it at 00:01 everyday....
TenmanS14 25-Jun-15 9:21am    
oops... mySQL, assuming your on a 'nix machine you do it with a cron job

 
Share this answer
 
v5
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900