Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Cannot insert the value NULL into column 'diagram_id'

Status
Not open for further replies.

ironhide1975

Programmer
Feb 25, 2003
451
US
Can someone offer any advice to fix this problem. Thank you in advance.

Code:
Cannot insert the value NULL into column 'diagram_id', table 'Central.dbo.sysdiagrams'; column does not allow nulls. INSERT fails.

The statement has been terminated.

The 'sp_creatediagram' procedure attempted to return a status of NULL, which is not allowed. A status of 0 will be returned instead. (.Net SqlClient Data Provider)


 
you need to check if the value you are trying to insert is null, if it is you will need to insert some default.

ISNULL(check expression,new value)



- Paul
- Database performance looks fine, it must be the Network!
 
Where would this null value be hidden? I'm presuming I'm missing something in the tables?

 
Let us say your table columns are:

C1 DATETIME NOT NULL
C2 VARCHAR(5) NOT NULL

If you try:

INSERT tablename (C1)
VALUES ('2006-11-20 11:00:00)

It will fail. Since no value is given for C2, it will have to enter a NULL. But NULLs are not allowed.

So, you need to look at what your code is inserting and what values the table expects. Compare the two and you should see where you are trying to insert a NULL.

-SQLBill


Posting advice: FAQ481-4875
 
Somewhere your sp_creatediagram procedure is trying to insert data into the diagram_id field. That field will not allow nulls. without having access to the procedure or the table structure I can't tell you where it is coming from. But if you cange the procedure to check for nulls before it inserts in toe diagram_id you won't get the error. For example, If diagram_id is an int, you could replace the null with 0 like this.
Code:
ISNULL(diagram_id, 0)


- Paul
- Database performance looks fine, it must be the Network!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top