• Difficult to know what you want to do because you haven't included expected output for any data.

    What is you expected output with the following: -

    DECLARE @NewTask VARCHAR(50), @StartDate DATETIME, @EndDate DATETIME;

    SET @NewTask = 'TASK D';

    SET @StartDate = '2012-03-04';

    SET @EndDate = '2012-03-05';

    DECLARE @NewTask VARCHAR(50), @StartDate DATETIME, @EndDate DATETIME;

    SET @NewTask = 'TASK D';

    SET @StartDate = '2012-03-14';

    SET @EndDate = '2012-03-17';

    Here's a shot in the dark: -

    DECLARE @NewTask VARCHAR(50), @StartDate DATETIME, @EndDate DATETIME;

    SET @NewTask = 'TASK D';

    SET @StartDate = '2012-03-14';

    SET @EndDate = '2012-03-17';

    IF EXISTS (SELECT 1 FROM MyTaskList WHERE @StartDate >= StartDate AND @StartDate <= EndDate)

    BEGIN

    PRINT 'StartDate No Good';

    END

    ELSE IF EXISTS (SELECT 1 FROM MyTaskList WHERE @EndDate >= StartDate AND @EndDate <= EndDate)

    BEGIN

    PRINT 'EndDate No Good';

    END

    ELSE BEGIN

    INSERT INTO MyTaskList (TaskName, StartDate,EndDate)

    SELECT @NewTask, @StartDate, @EndDate;

    END


    Forever trying to learn
    My blog - http://www.cadavre.co.uk/
    For better, quicker answers on T-SQL questions, click on the following...http://www.sqlservercentral.com/articles/Best+Practices/61537/
    For better, quicker answers on SQL Server performance related questions, click on the following...http://www.sqlservercentral.com/articles/SQLServerCentral/66909/