MS Access to SQL

When designs a database using a checkbox (Yes/No) and upsizes the database to SQL, What field type does SQL use as there is no Yes/No in SQL?
Gregory AmbroseAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Mike EghtebasDatabase and Application DeveloperCommented:

0 no
1 yes
Guru JiCommented:
You can use the Bit Data field which basically has 1 and 0 for Y or N. But if you want to be more flexible then use  char(1) then you can even put T/F in a column that also has Y/N, and even 1/0.
The equivalent is a bit field.

In SQL you use 0 and 1 to set a bit field (just as a yes/no field in Access). In Management Studio it displays as a false/true value (at least in recent versions).
You need to be careful about nulls.  Either SQL Server allows nulls or Jet/ACE does but the other doesn't.  I'm having a senior moment and can't remember which way it goes.   So, when I create Yes/No columns in Access, I always define them as required and populate them with a default true or false depending on what makes sense for the "question".  That makes upsizing easier.

Also, I recently had a gotcha in an app that was converted from ACE to SQL Server which apparently I had never run into before.  SQL Server does not apply defaults until a record is saved (which I knew but lost sight of) but Access applies them as soon as you type the first character and dirty a record.  In one particular form,  the code was looking at a Yes/No field and assuming it had a value (which it did when run with the Access BE but not with SQL server).  The simplest solution was to add defaults to the control on the form so that the form would populate the default.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Mike EghtebasDatabase and Application DeveloperCommented:
a bit has three options:
null tbd meaning no entry is made
0     false
1    true

IIF(Nz(FieldYN, "")<>"","Is either YES or NO'', "Is tbd")

You can use this to your advantage.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.