I have a table in which I have three fields which are:
create table horas
(
fechaEntrada datetime,
fechaSalida datetime,
horasEstimadas int
);
and I have to make a restriction in the table that is, that the estimated hours should not be greater than the hours on the date of entry and the date of departure.
Try a CHECK and in with a DATEDIFF but it always marks me wrong.
horasEstimadas int check (horasEstimadas <= (select DATEDIFF(DD, fechaEntrada, fechaSalida)))
And he sends me this error:
Subqueries are not allowed in this context. Only scalar expressions are allowed.
I'm using SQL SERVER 2008.
I do not know what to do, thank you in advance for reading.