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.
    
        | 
                
                    | 
                            
                                | Author | Topic |  
                                    | Karim174Starting Member
 
 
                                        5 Posts | 
                                            
                                            |  Posted - 2013-12-03 : 06:02:43 
 |  
                                            | Hello SQL Guru'sIm trying to add a column in a table but i get the following error;Msg 515, Level 16, State 2, Line 1Cannot 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 ) ;GOINSERT INTO DWH.DBO.incident (incident_ref)SELECT incident_refFROM incident;GOI create column as follow;alter table incidentadd incident_ref varchar(25)See picture1 how my table original table looksand picture2 how my table look like now   SQL GETTING A DREAM |  |  
                                    | visakh16Very Important crosS Applying yaK Herder
 
 
                                    52326 Posts | 
                                        
                                          |  Posted - 2013-12-03 : 06:30:05 
 |  
                                          | I cant view the imageBut 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 MVPhttp://visakhm.blogspot.com/https://www.facebook.com/VmBlogs |  
                                          |  |  |  
                                |  |  |  |