A NOT NULL Default

  • Comments posted to this topic are about the item A NOT NULL Default

  • This has the same output, what have I missed?

    Msg 515, Level 16, State 2, Line 6

    Cannot insert the value NULL into column 'myid', table 'database.dbo.NotNullTable'; column does not allow nulls. INSERT fails.

    The statement has been terminated.

    SET ANSI_NULL_DFLT_ON OFF
    GO
    CREATE TABLE NotNullTable
    ( myid INT)
    GO
    INSERT dbo.NotNullTable (myid) VALUES (NULL)
    GO
    DROP TABLE dbo.NotNullTable
    GO
  • What the other Ed said.

    Edward

  • Isn't this not the answer we weren't looking for 🙂

  • set ansi_null_dflt_ON OFF

    create table TDfTest(i int)

    insert into TDfTest values (NULL)

    --Cannot insert the value NULL into column 'i', table 'test.dbo.TDfTest'; column does not allow nulls. INSERT fails.

  • Arhh, poor testing matrix. Question allows either answer and points awarded back

  • Why would anyone want to turn off standard ANSI defaults? I thought these options were a legacy thing. Or is there some real reason to sue them still that I'm not aware of?

Viewing 7 posts - 1 through 6 (of 6 total)

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