Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Administration
 database table problem

Author  Topic 

michael999
Starting Member

9 Posts

Posted - 2011-12-04 : 17:12:53
hi
I have a database with several tables. But one is not allowing me to make changes to it.
The website is returning
Cannot insert the value NULL into column 'CustomerID', table 'xxxxxxxx.Customers'; column does not allow nulls. INSERT fails.

But the problem is with one table on the database. It was working OK but somehow the table settings changed.
The Identity specification is now set to No. I can change the settings to Yes and set is identity = Yes and I cannot save the changes.
I am supposed to be able to do it if I drop and recreate the tables!!

What do I need to do to sort this out please?

Michael



visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-12-04 : 23:43:09
If you want to insert value directly to identity column you need to make IDENTITY_INSERT ON
I think in your case problem is identity property is not enabled in CustomerID. Please note you cant modify a column directly to be of type identity. for that you need to do like below

http://www.mssqltips.com/sqlservertip/1397/add-or-drop-identity-property-for-an-existing-sql-server-column/

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -