Column does not allow nulls. INSERT fails

  • Hi all

    I am in the process of moving web hosts.

    I used Microsoft SQL Server Management Studio and the import data wizard to migrate my SQL database from Jodohost to Fasthosts. The software that the database is used by is WebWiz forums.

    The migration reported no errors, and when I change the connection to the Fasthosts SQL server it appears to work (I can unlock the forum for example), however when I try and make a test post I get the following error message

    Server Error in Forum Application

    An error has occured while writing to the database.

    Please contact the forum administrator.

    Support Error Code:- err_SQLServer_save_new_topic_data

    File Name:- new_post.asp

    Error details:-

    Microsoft OLE DB Provider for SQL Server

    Cannot insert the value NULL into column 'Topic_ID', table 'balearic_forum.dbo.tblTopic'; column does not allow nulls. INSERT fails.

    I would really appreciate any advice. Please be gentle, I'm learning on the fly with this stuff, I'm far from a website developer.

    Thank you.

  • Well, the error means that the application is trying to insert no value or null value into the column "Topic_ID" which seems to be a non-nullable column in the table.

    I suspect that the column looks to be an identity but has not set set the identity property or the IDENTITY_INSERT option is set to ON for the table.

    --Ramesh


  • I suspect that the topic_id column is an identity column on the old server and when you transferred the definitions/data to the new server the identity property was not on the included.

    You should be able to check this by comparing the definitions of both tables. If you script them, have a look for something like

    topic_id int IDENTITY (1, 1)

    (I am guessing the data type to be INT)

    I think that the "IDENTITY (1, 1)" is missing from the new server.

    The reason for the error message is when a column has this property, SQL Server automatically generates a value for the column (similar to AUTONUM in MS-Access) and you are not allowed to include the column in the INSERT statement.

    (Actually, you can specify the column / value in an INSERT statement but that is not applicable here).

    If you can, why not simply backup the old database and restore it to the new server ? Once there, all database structures will be correct. You may need to adjust Users (you can use sp_change_users_login can help with this) and then you should be OK.

    Otherwise, you can try transferring everything. Make sure you check that the setting of what you are copying. Unfortunately, I don't have an instance of SQL to test with and I can remember the dialogues you will see.

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

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