Hi,
I have a table that has 4 fields called TblStaffLeave ( PersonnelNo (PK), LeaveType(Int),StartDate (date), EndDate(date)
Example data look like
PersonnelNo, LeaveType,StartDate,EndDate
1234 , 1 , 1/7/2017, 17/7/2017
4353 , 1 , 15/8/2017, 19/9/2017
1234 , 2 , 13/4/2017, 23/5/2017
.
.
.
I want to use this data to populate a second table called TblStaffRoster, that has 15 columns, the first is the PersonnelNo (int PK) followed by 14 consecutive dates starting from a Monday each column is of type int. So I want to insert the LeaveType from TblStaffLeave into the column with the corresponding dates! So some staff may have all leave in the 14 columns other may have none.
Is there a way to use a cursor as in TSQL ?
I think it can be done using sql or vba code but prefer to do it in sql if possible.
All help appreciated
Gerry
I have a table that has 4 fields called TblStaffLeave ( PersonnelNo (PK), LeaveType(Int),StartDate (date), EndDate(date)
Example data look like
PersonnelNo, LeaveType,StartDate,EndDate
1234 , 1 , 1/7/2017, 17/7/2017
4353 , 1 , 15/8/2017, 19/9/2017
1234 , 2 , 13/4/2017, 23/5/2017
.
.
.
I want to use this data to populate a second table called TblStaffRoster, that has 15 columns, the first is the PersonnelNo (int PK) followed by 14 consecutive dates starting from a Monday each column is of type int. So I want to insert the LeaveType from TblStaffLeave into the column with the corresponding dates! So some staff may have all leave in the 14 columns other may have none.
Is there a way to use a cursor as in TSQL ?
I think it can be done using sql or vba code but prefer to do it in sql if possible.
All help appreciated
Gerry