default constraint not working on table

  • i created a table with a default constraint on a column, as shown below:

    create

    table Log_DIMFCT

    (

    sprocName

    varchar(30),

    begin_end

    varchar(10),

    entryTime

    datetime not null default getdate()

    )

     

    when i try to insert into the table i use this line:

     

    insert

    into log_Dimfct values('test','start')

     

    i get an error saying i did not specify the same amount of data as there are columns. i thought the default constraint would fill in the date col. am i not correct in this assumption?

  • if you're not providing values for all columns (except for identities) of a table, you should tell it which columns you're providing (values-order must match columnorder in the column-list ).

     

    insert into log_Dimfct ( sprocName ,begin_end) values('test','start')

    Johan

    Learn to play, play to learn !

    Dont drive faster than your guardian angel can fly ...
    but keeping both feet on the ground wont get you anywhere :w00t:

    - How to post Performance Problems
    - How to post data/code to get the best help[/url]

    - How to prevent a sore throat after hours of presenting ppt

    press F1 for solution, press shift+F1 for urgent solution 😀

    Need a bit of Powershell? How about this

    Who am I ? Sometimes this is me but most of the time this is me

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

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