Setting Defaults in an Insert Into command for SQL

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • stellaNY
    New Member
    • Nov 2007
    • 1

    Setting Defaults in an Insert Into command for SQL

    Hi,

    I have an issue where I am using INSERT INTO a Customer table with 36 fields- I have information for 2 fields and the

    INSERT INTO [Customer](
    [No_],[Name])
    VALUES ('q1234','EP')

    I get an error message..

    Msg 515, Level 16, State 2, Line 2
    Cannot insert the value NULL into column 'Search Name', table 'Customer'; column does not allow nulls. INSERT fails.
    the statement has been terminated.


    Is there a way to default the other fields to SPACE or something other than NULL - without defining every field.

    Thanks
  • iburyak
    Recognized Expert Top Contributor
    • Nov 2006
    • 1016

    #2
    Try this:

    Code:
    INSERT INTO [Customer]( 
    [No_],[Name],[Search Name])
    VALUES ('q1234','EP','')
    Or
    you can set a default in table designer.

    Good Luck.

    Comment

    Working...