By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,364 Members | 1,358 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,364 IT Pros & Developers. It's quick & easy.

Data Type

P: n/a
I am a SQL newbie! What is the correct datatype to use, if I want to record
a checkbox from a web form? Thanks,
Darren
Jul 20 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Scrappy (ce*****@lan-specialist.com) writes:
I am a SQL newbie! What is the correct datatype to use, if I want to
record a checkbox from a web form? Thanks,


The most natural type to use would be bit, which only can hold the values 0
or 1.

If you want to stick to standards, you may avoid this datatype since it
is propritary to SQL Server and Sybase (or at least so claims Joe Celko).
In such case a char(1) column with the values T/F ot Y/N could be an
alternative. Or a tinyint column with the values 0/1.

--
Erland Sommarskog, SQL Server MVP, so****@algonet.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinf...2000/books.asp
Jul 20 '05 #2

P: n/a
"Erland Sommarskog" <so****@algonet.se> wrote in message news:Xn**********************@127.0.0.1...
Scrappy (ce*****@lan-specialist.com) writes:
I am a SQL newbie! What is the correct datatype to use, if I want to
record a checkbox from a web form? Thanks,
The most natural type to use would be bit, which only can hold the values 0
or 1.

If you want to stick to standards, you may avoid this datatype since it
is propritary to SQL Server and Sybase (or at least so claims Joe Celko).


Hi Erland, actually, BIT, and the more general BIT(n), are defined in both
SQL:1992 and SQL:1999. I believe the difference is that the Standard
requires a bit string literal to be written like B'1'. Not sure if the integer
1 would be automatically cast to B'1' but seems reasonable.

Regards,
jag
In such case a char(1) column with the values T/F ot Y/N could be an
alternative. Or a tinyint column with the values 0/1.

--
Erland Sommarskog, SQL Server MVP, so****@algonet.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinf...2000/books.asp

Jul 20 '05 #3

P: n/a
>> the more general BIT(n), are defined in both SQL:1992 and SQL:1999 <<

Yes, and in the Standards, you treat them as if they were character
strings. The operations are bit string comparison, assignment, bit
concatenation operator, bit substring function, length, and position.
You do not have bit-wise operators like you do in T-SQL or assembly
language.

When you try to use them with a host languages, you get all kinds of
problems -- high end or low end bytes? Does 0 or 1 mean "TRUE"?

--CELKO--
===========================
Please post DDL, so that people do not have to guess what the keys,
constraints, Declarative Referential Integrity, datatypes, etc. in your
schema are.

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 20 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.