Your select statement doesn't specify which table it should get the data from, so nothing is returned and the table is not created with the fields you want.
e.commencementdate as CommencementDate
If the table isn't named 'e' substitute it with the actual table name.
And if you want to join FieldStaff on TotalHoursWorked then you'll probably want to make sure the field you join them on has the same name in both tables.
Thanks Gisbert. I left out the FROM cluase in my SQL, but do I have that in my code.
What I want to know is how to reference a column in my FieldStaff table in my script, and use that value in my Load statement further down, in the Select section (ShiftDate - CommencementDate) (ShiftDate is from the QVD file, CommencementDate is from my FieldStaff table), or in a WHERE cluase when accessing the QVD file
(WHERE ShifDate >= CommencementDate OR ShiftDate < CommencementDate + 30)
WHERE ShifDate >= FieldStaff.CommencementDate OR ShiftDate < FieldStaff.CommencementDate + 30).