Tim Huffam

Dotting the I and crossing the T of I.T.

  Home  |   Contact  |   Syndication    |   Login
  153 Posts | 0 Stories | 2422 Comments | 653 Trackbacks

News

Archives

Post Categories

Interesting Blogs/Links

When modifying a table SQL Server (2005) and unchecking a column's 'Allow Nulls' (ie trying to make the column Not Null) the following error may occur:
'<tablename>' table
- Unable to modify table. 
Cannot insert the value NULL into column '<columnname>', table '<dbname>.dbo.Tmp_<tablename>'; column does not allow nulls. INSERT fails.
The statement has been terminated.
This occurs if there is already data in this table and this column contains nulls.
 
The solution is to simply update the data in this table so that this column does not contain nulls then change the column to not null.  eg if this column was of type int you could do this:

UPDATE [<dbname>].[dbo].[<tablename>]
    SET [<integercolumnname] = -1

posted on Thursday, May 29, 2008 9:05 PM

Feedback

# protect from insert null value 8/13/2009 12:38 PM Shahul
Dear All,
While Click data insert in to table and Textbox became null;
When i Click once more The Null all inserting in to Table. i want to protect this...

# Solution 12/16/2011 6:39 PM vivi
Go to excel and copy all (ctrl + e )

paste in another book ,

and try again (import to sql , etc )

that works for me , i think that when we fill the shelds just moving down our mouse there's a formula or kind of format that sql detect as an empty (null)...and when we past the data in another book it pasted like a numbers and then sql recognised it XD .. something like that ..


Post A Comment
Title:
Name:
Email:
Website:
Comment:
Verification: