Home » Database, SQL

SQL Error: Cannot insert the value NULL into column… column does not allow nulls. INSERT fails.

10 March 2009 267 views No Comment

Error description:

Cannot insert the value NULL into column ‘SourceId’, table ‘Advisory.dbo.AdvDocSource’; column does not allow nulls. INSERT fails.
The statement has been terminated. The ‘CompanyAdd’ procedure attempted to return a status of NULL, which is not allowed. A status of 0 will be returned instead.
——————————-

This error occurs because the ‘SourceId’ column in my table is primary key and it is set to not null. i.e. it doesn’t allow null entries. And I have not made it auto increment.

For making a table column auto increment:
- Go to server explorer.
- In Column Properties, go to Identity Specification.
- Go to (Is Identity) and make it ‘Yes’ from the selection list.

You are done. You also have the option for Identity Increment and Identity Seed.

The SQL Query is:
CREATE TABLE [yourTableName](SourceID int IDENTITY(1,1) NOT NULL, …

Popularity: 8%

Related posts:

  1. Configuration error on new Magento installation
  2. Displaying all products and new products listing in column/grid layout – Zen-cart
  3. ASP.NET Error: A potentially dangerous Request.Form value was detected from the client
  4. PHP extension error while installing Magento
  5. ASP.NET Error : An HtmlSelect cannot have multiple items selected when Multiple is false.
Share/Bookmark
1 Star2 Stars3 Stars4 Stars5 Stars (2 votes, average: 5.00 out of 5)
Loading ... Loading ...

Leave your response!

Add your comment below, or trackback from your own site. You can also subscribe to these comments via RSS.

Be nice. Keep it clean. Stay on topic. No spam.

You can use these tags:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

This is a Gravatar-enabled weblog. To get your own globally-recognized-avatar, please register at Gravatar.