create a check constraint on the tablecreate a udfsomething likeCREATE FUNCTION RecCnt(@timein datetime,@timeout datetime)RETURNS intASBEGIN DECLARE @Cnt intSELECT @Cnt=COUNT(*)FROM YourTableWHERE DATEDIFF(minute,@timein,timein) <= 45OR DATEDIFF(minute,@timeout,timeout) <= 45RETURN(@Cnt)END
then use it likeALTER TABLE YourTable ADD CONSTRAINT Chk_TimeOverlap CHECK (dbo.RecCnt(timein,timeout) = 0 )
------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/https://www.facebook.com/VmBlogs