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

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
Save Password
Forgot your Password?

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 Try to add a column
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Starting Member

5 Posts

Posted - 12/03/2013 :  06:02:43  Show Profile  Reply with Quote
Hello SQL Guru's

Im trying to add a column in a table but i get the following error;

Msg 515, Level 16, State 2, Line 1
Cannot insert the value NULL into column 'incident_id', table 'DWH.dbo.incident'; column does not allow nulls. INSERT fails.

I use the following syntax to add the column ( I copy a previous column from a other table ) ;

INSERT INTO DWH.DBO.incident (incident_ref)
SELECT incident_ref
FROM incident;

I create column as follow;

alter table incident
add incident_ref varchar(25)

See picture1 how my table original table looks

and picture2 how my table look like now


Very Important crosS Applying yaK Herder

52326 Posts

Posted - 12/03/2013 :  06:30:05  Show Profile  Reply with Quote
I cant view the image
But error message suggests you're trying to insert NULL value to 'incident_id' column which is declared as NOT NULL and hence its failing. So either make it as NULLable or if it has to have a value always check the query on why its getting some NULL values.

Also the insert statement above doesnt include this column. So unless its declared as an IDENTITY column or has a default constraint, INSERT will break if 'incident_id' is NOT NULL.

SQL Server MVP
Go to Top of Page
  Previous Topic Topic Next Topic  
 Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.02 seconds. Powered By: Snitz Forums 2000