Sql-server – Auto increment a value using cursor in SQLServer

auto-incrementcursorssql server

I am developing an employee leave management system and

My table structure with data is :

+-----------+---------+----------+----------+------------+--------------+
|   EmpID   |   CL    |     PL   | ISActive | LastUpdate |  NextUpdate  |
+-----------+---------+----------+----------+------------+--------------+
|   E001    |   5     |     3    |    1     | 2015-01-01 |  2015-02-01  |
+-----------+---------+----------+----------+------------+--------------+
|   E002    |   3     |     7    |    1     | 2015-01-01 |  2015-02-01  |
+-----------+---------+----------+----------+------------+--------------+
|   E003    |   0     |     1    |    1     | 2015-01-01 |  2015-02-01  |
+-----------+---------+----------+----------+------------+--------------+
|   E004    |   5     |     1    |    0     | 2015-01-01 |  2015-02-01  |
+-----------+---------+----------+----------+------------+--------------+

I want every active employee to get 2 CL on the 1st of every month and
1 SL every 45 days automatically. I have been told it is possible to do this using a cursor, but i don't know.

Is there any other efficient way to do this?

Best Answer

I also agree with @James Anderson you would have to use SQL Agent for better result.

If you don't know how to setup a SQL Job then, Please see this link for your reference how to set a SQL Job.