Friday, February 10, 2012

bit data type

I run a simple select statement to a table that selects
data. One of the column's data type is "bit" size "1" set
to default to ((-1)).
Here is the problem, when I run a select statement in
query analyzer, all data from that column is "1". When I
run the same query and use DTS to export the data to a
text file, all the data from that column is "true". What
does that mean and how can I get the data to just be "1"?
Please help.
Thanks. John.The valid values of a BIT column are 0, 1 and NULL, so there's no good
reason to default the column to -1. The -1 will be implicitly cast to 1,
which is one of the peculiarities of the BIT datatype.
DTS assumes that you want BIT columns to be treated as Boolean values and
chooses to export them as the strings "True" and "False". You can avoid this
by casting the value as an INTEGER in your transformation. Alternatively,
choose another numeric type for the column instead of BIT.
--
David Portas
SQL Server MVP
--|||Thank you very much. That makes sense.
John
>--Original Message--
>The valid values of a BIT column are 0, 1 and NULL, so
there's no good
>reason to default the column to -1. The -1 will be
implicitly cast to 1,
>which is one of the peculiarities of the BIT datatype.
>DTS assumes that you want BIT columns to be treated as
Boolean values and
>chooses to export them as the strings "True" and "False".
You can avoid this
>by casting the value as an INTEGER in your
transformation. Alternatively,
>choose another numeric type for the column instead of BIT.
>--
>David Portas
>SQL Server MVP
>--
>
>.
>|||Hi
VB: -1 = True
All other languages: +1 = True.
--
Mike Epprecht, Microsoft SQL Server MVP
Johannesburg, South Africa
Mobile: +27-82-552-0268
IM: mike@.epprecht.net
MVP Program: http://www.microsoft.com/mvp
Blog: http://www.msmvps.com/epprecht/
"John" <anonymous@.discussions.microsoft.com> wrote in message
news:18ba01c47be5$ba2b8cc0$a601280a@.phx.gbl...
> Thank you very much. That makes sense.
> John
>
> >--Original Message--
> >The valid values of a BIT column are 0, 1 and NULL, so
> there's no good
> >reason to default the column to -1. The -1 will be
> implicitly cast to 1,
> >which is one of the peculiarities of the BIT datatype.
> >
> >DTS assumes that you want BIT columns to be treated as
> Boolean values and
> >chooses to export them as the strings "True" and "False".
> You can avoid this
> >by casting the value as an INTEGER in your
> transformation. Alternatively,
> >choose another numeric type for the column instead of BIT.
> >
> >--
> >David Portas
> >SQL Server MVP
> >--
> >
> >
> >.
> >

No comments:

Post a Comment