Cannot insert or change the value NULL into new column and old columns

  • HERE IS THE ERROR I GET

    'ORDENES' table

    - Unable to modify table.

    Cannot insert the value NULL into column 'MONEDA', table 'ordenesSQL.dbo.Tmp_ORDENES'; column does not allow nulls. INSERT fails.

    The statement has been terminated.

    I hope someone can tell me why is this problem.

    I can create columns but onlu with allow nulls marked.

    Note: my database was created using Microsoft SQL Server Migration Assistan 2008 for Access

  • Have you installed SSMS and connected to your server?

    For a newbie, navigate to the table, right click modify, then check the allow nulls where applicable.

    You can download SSMS express and that should do fine.

    Cheers
    http://twitter.com/widba
    http://widba.blogspot.com/

  • can be more explicit, im using SQL Server 2008, you say that i need to install SSMS to do that, and why i can't do that with the SSMS that comes with SQL Server 2008?

  • If you have it installed, your all set.

    Connect up and edit the table - whats the issue?

    Obviously going from a nullable field to non nullable will require you to fill in the null columns.

    Cheers
    http://twitter.com/widba
    http://widba.blogspot.com/

  • OK I UNDERSTAD YOUR POINT, BUT FOR EXAMPLE I CHECK THE EXISTING COLUMN NAMED "TRABAJO" WITH THIS:

    SELECT * FROM ORDENES WHERE TRABAJO = NULL

    AND I HAVE NO RESULTS, THAT MEANS NO RECORDS ARE EMPTY, WHY I CANT CHANGE THAT COLUMN TO NOT NULL, I GET THE SAME ERROR, AND PLEASE GIVE AND EXAMPLE TO UPDATE ALL THE EXISTING RECORDS IN THE NEW CREATED COLUMNS TO ALLOW THE CHANGE TO NOT NULL, CAN YOU HELP ME WITH THAT?

  • Another fun fact : NULL never equals NULL

    SELECT * FROM ORDENES WHERE TRABAJO = NULL

    The correct way:

    SELECT * FROM ORDENES WHERE TRABAJO IS NULL

    UPDATE <schema>.ORDENES

    SET trabajo = 'wasoncenull'

    WHERE trabajo IS NULL

    ALTER TABLE ORDENES

    ALTER trabago <datatype> NOT NULL

    hopefully that gets you going in the right direction

    Cheers
    http://twitter.com/widba
    http://widba.blogspot.com/

  • ohhh yes! it works now! now i cant set the columns to not null,i just fill the null records as you said! thanks a lot, i will be here looking for help because im migrating a system that had a MS Access database and im correcting the errors that comes with the change of databases, great great help!

    sorry im from mexico, and my english isn't so good

  • Good luck on your project.

    Buenos Nochas! (my weak Espanol for good night)

    Cheers
    http://twitter.com/widba
    http://widba.blogspot.com/

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

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