I have a SQL Server database containing a timesheet . This table is used to store roles for employees. Before performing the insert, which I check to see that the employee has previous roles on the selected days.
A procedure is stored here that returns the number of pre-existing roles.
set @retVal=(select count(fk_RoleID) from dbo.TimesheetTable where (@startdate >= CAST(( STR( YEAR( StartDate ) ) + '/' + STR( MONTH( StartDate ) ) + '/' + STR( DAY( StartDate ) ) ) AS DATE ))
The following are entries for one employee.
pk_ID fk_PersonnelID fk_RoleID StartDate EndDate dateCreated 62 1 26 2012-10-01 2012-10-02 2012-10-25 15:55:12.940 81 1 20 2012-10-04 2012-10-06 2012-10-30 14:50:28.300
If I try to do an insert where the start date is 2012-10-05 and the end date is 2012-10-11 , the request will not be able to capture startdate .. and the insert happens
What am I doing wrong?
source share