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.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Null Value in Boolean Field

Author  Topic 

josh2009
Yak Posting Veteran

81 Posts

Posted - 2010-06-15 : 10:45:11
Hi,

Is there a way for me to limit the the field values of a boolean to just 0 and 1? I've got a table with a boolean field that is displayed to user as a check box in a grid. Upon display it starts off with a null value and user needs to click twice in the check box to actually select. My users are physicians who would be very happy if I can have the field toggle between 0 and 1 values only so they only have to click once. I have tried defaulting the field to a 0 but when I run it, it still displays the null state in my pop-up form using visual studio. I tried to uncheck the allow nulls but when I try to save my change to disallow nulls, I get an error message - "Unable to modify table. Cannot insert the value NULL into column 'NoteSelected', table 'Apollo_Test.dbo.Tmp_Cath_AdditionalFindings_SNLog'; column does not allow nulls. INSERT fails. The statement has been terminated." so I'm stuck with the null state still. Any help will be greatly appreciated. Thanks

X002548
Not Just a Number

15586 Posts

Posted - 2010-06-15 : 11:55:51
...kinda makes me laugh...just a identity can't be null, they should have mad boolean that way...

just put a constraint on it

M$ techs aren't thinking...unless you want to argue that unknown is ok

OK...I talked myself into a corner there....



Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx

Add yourself!
http://www.frappr.com/sqlteam



Go to Top of Page

josh2009
Yak Posting Veteran

81 Posts

Posted - 2010-06-15 : 12:35:24
Hi,

Thanks for the quick reply. I ran the ff stmt - ALTER TABLE Cath_AdditionalFindings_SNLog ADD CONSTRAINT DF_Cath_AdditionalFindings_SNLog_NoteSelected DEFAULT 0 FOR NoteSelected. However, when I displayed the field again in my pop-up window, it still starts out with the null state in the check box so I still have to click twice to select the note. Again, thanks for your help.

Go to Top of Page
   

- Advertisement -