I have a table name Overtime Hours which have the following columns
Ot_ID, Shift_Date, Employee_ID, Hours.
What I need to do is insert a set of values in these tables on the 1st date of every month, automatically.
for example, I need to add values(‘1/1/2010’,12345,4.6) for january,
values(‘2/1/2010’,12345,4.6) for february and so on for the whole year.
This addition has to be done so a certain list of employees only and the Hours value is constant for every month.
I am working on MS SQL Server 2000 in the backend. and visual studio, Winforms on C sharp in the front end.
You can create a list of months using a common table expression. Use cross join to generate a row for each employee for each month, and insert that into the hours table.
Some example code, with table variables: