Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Best ODBC data type for Boolean data

3 views
Skip to first unread message

Andrew Chalk

unread,
Dec 16, 2002, 2:57:34 PM12/16/02
to
I have some data in memory that is represented by Boolean values. When I
write this to a table with ODBC what is the best choice of ODBC data type
and SQL data type?

Many thanks.


Bob Hairgrove

unread,
Dec 16, 2002, 4:10:26 PM12/16/02
to

A lot of people use either INTEGER or CHAR(1). You can set up the
field like this:

CREATE TABLE foo (
bar INTEGER NOT NULL DEFAULT 0,
/* ... */
CONSTRAINT chk_bar CHECK (bar IN (0, 1)));

or like this:

CREATE TABLE foo (
bar CHAR(1) NOT NULL DEFAULT '0',
/* ... */
CONSTRAINT chk_bar CHECK (bar IN ('0', '1')));

MS-Access uses a non-standard "integer" which is actually an
SQL_SMALLINT with values of 0 or -1.


Bob Hairgrove
rhairgro...@Pleasebigfoot.com

Andrew Chalk

unread,
Dec 16, 2002, 4:48:34 PM12/16/02
to
Many thanks!

"Bob Hairgrove" <rhairgro...@Pleasebigfoot.com> wrote in message
news:3dfe4040...@news.webshuttle.ch...

Michael Visintin

unread,
Dec 17, 2002, 12:16:07 PM12/17/02
to
If you will have a lot of records of this type and want to save space, then
use a bit field. You can store a 0 or 1 there.

Keep in mind that the VB code will interpret it as True or False, not 0 and
1.

Michael

"Andrew Chalk" <ach...@NOSPAMmagnacartasoftware.com> wrote in message
news:O56uvzUpCHA.704@TK2MSFTNGP09...

Andrew Chalk

unread,
Dec 17, 2002, 4:43:51 PM12/17/02
to
Thanks.

"Michael Visintin" <Michael....@eaglepoint.com> wrote in message
news:erin4$epCHA.640@TK2MSFTNGP12...

0 new messages