SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 How to insert into a BIT datatype
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

simflex
Constraint Violating Yak Guru

315 Posts

Posted - 07/31/2013 :  12:17:54  Show Profile  Reply with Quote
Can someone please help with inserting values into a bit data type?

We have a checkbox on one of our forms.

If a user checks this box and clicks the Save button, we would like to have a value of 1 or True inserted into the table.

If however, the box is not checked, rather than inserting NULL, we would like to insert 0 or False.

Any idea how to solve this?


Thanks alot in advance

SwePeso
Patron Saint of Lost Yaks

Sweden
30265 Posts

Posted - 07/31/2013 :  12:37:08  Show Profile  Visit SwePeso's Homepage  Reply with Quote
1 and 0 will evaluate as bit set and bit not set (true and false).



Microsoft SQL Server MVP, MCT, MCSE, MCSA, MCP, MCITP, MCTS, MCDBA
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

India
52323 Posts

Posted - 08/01/2013 :  02:58:07  Show Profile  Reply with Quote
quote:
Originally posted by simflex

Can someone please help with inserting values into a bit data type?

We have a checkbox on one of our forms.

If a user checks this box and clicks the Save button, we would like to have a value of 1 or True inserted into the table.

If however, the box is not checked, rather than inserting NULL, we would like to insert 0 or False.

Any idea how to solve this?


Thanks alot in advance



Check the status of checbox (checkbox checked/not checked) in your front end application code and pass value as 1 or 0 to the database.

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
Go to Top of Page
  Previous Topic Topic Next Topic  
 New 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.03 seconds. Powered By: Snitz Forums 2000