• Hi Chandu,

    I think CHECK constraint checks AFTER insertion of data. If we do row count in the ckeck constraint it will have the new row. See the following example:

    CREATE TABLE CheckTbl (col1 int, col2 int);

    GO

    CREATE FUNCTION CheckFnctn()

    RETURNS int

    AS

    BEGIN

    DECLARE @retval int

    SELECT @retval = COUNT(*) FROM CheckTbl

    RETURN @retval

    END;

    GO

    ALTER TABLE CheckTbl

    ADD CONSTRAINT chkRowCount CHECK (dbo.CheckFnctn() >= 1 );

    GO

    insert into CheckTbl values (1, 1)

    (1 row(s) affected)