Default Constraint

  • Hi Experts,

    I created a default constraint with value (0) on BIT datatype and NOT NULL column. In the insert list i have not specified the column name. I guess it should take default value (0). But its throwing me a error

    "Cannot insert NULL values". Please help me in resolving this.

    Thanks in advance.

    Regards,

    Vijay

  • Vijay

    Please post your full INSERT statement and the DDL for your table.

    Thanks

    John

  • I don't think there should be a problem. Here is the sample code which executed perfectly

    CREATE TABLE dftBIT

    (

    id INT,

    flag BIT NOT NULL DEFAULT(0)

    )

    INSERT INTO dftBIT

    (id)

    VALUES (1)

    SELECT *

    FROM dftBIT

    In-case you face trouble kindly post associated DDL and DML.

    ~ Lokesh Vij


    Guidelines for quicker answers on T-SQL question[/url]
    Guidelines for answers on Performance questions

    Link to my Blog Post --> www.SQLPathy.com[/url]

    Follow me @Twitter

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply