Avatar of Sok Dymang
Sok DymangFlag for Cambodia

asked on 

create trigger to reset value every one year in sql server

Dear all brothers and sisters, i have a table "tbl_anualLeave" and default annual leave value for all user is 8, so when HR input amount of user take leave it will take that data to calculate with 8 and update the result to the table of that user,  no matter how user use all of their annual leave amount, the system will reset their current remain to 8 every (new year) - Jan -01, it mean that their annual leave will automatically reset to 8 every new year.  Thanks in advance
Microsoft SQL Server.NET ProgrammingVisual Basic.NET

Avatar of undefined
Last Comment
Vitor Montalvão
Avatar of Nitin Sontakke
Nitin Sontakke
Flag of India image

You don't need a trigger for that. You need a scheduled job for that which is (obviously) scheduled to execute once in a year.
Avatar of Sok Dymang
Sok Dymang
Flag of Cambodia image


Oh, so can you tell me how?
Avatar of Nitin Sontakke
Nitin Sontakke
Flag of India image

Blurred text
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
You don't need a trigger because a trigger isn't a scheduled task.
You'll need to create a SQL Agent job to run the necessary code to reset the required value.
Microsoft SQL Server
Microsoft SQL Server

Microsoft SQL Server is a suite of relational database management system (RDBMS) products providing multi-user database access functionality.SQL Server is available in multiple versions, typically identified by release year, and versions are subdivided into editions to distinguish between product functionality. Component services include integration (SSIS), reporting (SSRS), analysis (SSAS), data quality, master data, T-SQL and performance tuning.

Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews


IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo