Problem on insert into sql server 2005 table

  • DDL for table

    Create table dbo.email_template (

    ID int not null,

    template_name NVARCHAR(200) not null,

    content ntext not null,

    last_modified datetime null)

    on [PRIMARY] ;

    INSERT Statement

    insert into dbo.email_template

    (template_name, content, last_modified)

    values ('GenericContactNoAddress.vm',

    'This form was submitted from $serverName $formName

    $firstName $lastName

    $city $state

    Preferred method of contact: $preferredMethodOfContact

    Home Phone Number: $homePhone

    Work Phone Number: $workPhone

    Fax: $fax

    Email Address: $email

    My comments are:

    $comments',

    getDate()

    );

    Error:

    Msg 515, Level 16, State 2, Line 1

    Cannot insert the value NULL into column 'ID', table email_template'; column does not allow nulls. INSERT fails.

    The statement has been terminated.

    can anyone help?

  • The ID column is not identity column so it won't generate the value for missing (NOT NULL) column at the time of INSERT. Either declare the ID column as identity or insert the explicit values in INSERT statements.

  • I missed that.. THANK YOU!!!!

  • Jpotucek (1/5/2012)


    I missed that.. THANK YOU!!!!

    Most Welcome! 🙂

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

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