Sunday, March 25, 2012

Access Boolean to SqlServer

Hi. In Access I can set a field as Boolean ... what´s the equivalent for SqlServer?BIT, perhaps. (0, 1, or NULL).
Or, several workarounds. CHAR(1) with 'T' or 'F', 'Y' or 'N', etc.
--
http://www.aspfaq.com/
(Reverse address to reply.)
"KenA" <KenA@.discussions.microsoft.com> wrote in message
news:1354FE6C-F45A-4D01-A8CA-AFFB0073A6DC@.microsoft.com...
> Hi. In Access I can set a field as Boolean ... what´s the equivalent for
SqlServer?|||Quick suggestion from years of experience...
Don't use BIT fields - use the CHAR(1) with T or F; or with Y or N.
MS SQL with all it's connectivity potential with other tools - EXCEL, Crystal, etc - should not have "cryptic" values stored in columns. It's so much nicer to connect to a table and see a Y or N instead of a 1 or 0 (or -1 or 0 depending on what denotes true from false!).
Your non-tech users will appreciate this.
"Aaron [SQL Server MVP]" wrote:
> BIT, perhaps. (0, 1, or NULL).
> Or, several workarounds. CHAR(1) with 'T' or 'F', 'Y' or 'N', etc.
> --
> http://www.aspfaq.com/
> (Reverse address to reply.)
>
>
> "KenA" <KenA@.discussions.microsoft.com> wrote in message
> news:1354FE6C-F45A-4D01-A8CA-AFFB0073A6DC@.microsoft.com...
> > Hi. In Access I can set a field as Boolean ... what�´s the equivalent for
> SqlServer?
>
>|||Steve,
Depends on whether you are talking about displaying information to users
or storing it in a database. A bit field is my preferred datatype for
storing booleans as they take up less space and can only accept three
values, 1, 0, NULL (if you can call NULL a value).
The front end application should translate the bit column to a Y/N, or
1/0, checked/unchecked so the user doesn't ahve to guess. That is the
function of the front-end.
You do make a good point for users that have direct access into SQL Server.
--
Mark Allison, SQL Server MVP
http://www.markallison.co.uk
Looking for a SQL Server replication book?
http://www.nwsu.com/0974973602.html
Steve Z wrote:
> Quick suggestion from years of experience...
> Don't use BIT fields - use the CHAR(1) with T or F; or with Y or N.
> MS SQL with all it's connectivity potential with other tools - EXCEL, Crystal, etc - should not have "cryptic" values stored in columns. It's so much nicer to connect to a table and see a Y or N instead of a 1 or 0 (or -1 or 0 depending on what denotes true from false!).
> Your non-tech users will appreciate this.
> "Aaron [SQL Server MVP]" wrote:
>
>>BIT, perhaps. (0, 1, or NULL).
>>Or, several workarounds. CHAR(1) with 'T' or 'F', 'Y' or 'N', etc.
>>--
>>http://www.aspfaq.com/
>>(Reverse address to reply.)
>>
>>
>>"KenA" <KenA@.discussions.microsoft.com> wrote in message
>>news:1354FE6C-F45A-4D01-A8CA-AFFB0073A6DC@.microsoft.com...
>>Hi. In Access I can set a field as Boolean ... what�´s the equivalent for
>>SqlServer?
>>|||And I fall in-between Mark and Ken...
I try to decide what is the primary function for the boolean... If the
answer is for high speed searching then I'll more likely use a bit ( or even
an integer for 32 booleans). If the primary use will simply be for
reporting, then I'd probably use a char(1), so drag.drop report stuff will
be easy...
You could also use bit in the table, and provide a view which exposes the
bit value as a char(1) and get the best of both worlds.
--
Wayne Snyder, MCDBA, SQL Server MVP
Mariner, Charlotte, NC
www.mariner-usa.com
(Please respond only to the newsgroups.)
I support the Professional Association of SQL Server (PASS) and it's
community of SQL Server professionals.
www.sqlpass.org
"Mark Allison" <marka@.no.tinned.meat.mvps.org> wrote in message
news:eZQIDKAYEHA.3012@.tk2msftngp13.phx.gbl...
> Steve,
> Depends on whether you are talking about displaying information to users
> or storing it in a database. A bit field is my preferred datatype for
> storing booleans as they take up less space and can only accept three
> values, 1, 0, NULL (if you can call NULL a value).
> The front end application should translate the bit column to a Y/N, or
> 1/0, checked/unchecked so the user doesn't ahve to guess. That is the
> function of the front-end.
> You do make a good point for users that have direct access into SQL
Server.
> --
> Mark Allison, SQL Server MVP
> http://www.markallison.co.uk
> Looking for a SQL Server replication book?
> http://www.nwsu.com/0974973602.html
>
> Steve Z wrote:
> > Quick suggestion from years of experience...
> >
> > Don't use BIT fields - use the CHAR(1) with T or F; or with Y or N.
> >
> > MS SQL with all it's connectivity potential with other tools - EXCEL,
Crystal, etc - should not have "cryptic" values stored in columns. It's so
much nicer to connect to a table and see a Y or N instead of a 1 or 0 (or -1
or 0 depending on what denotes true from false!).
> >
> > Your non-tech users will appreciate this.
> >
> > "Aaron [SQL Server MVP]" wrote:
> >
> >
> >>BIT, perhaps. (0, 1, or NULL).
> >>
> >>Or, several workarounds. CHAR(1) with 'T' or 'F', 'Y' or 'N', etc.
> >>
> >>--
> >>http://www.aspfaq.com/
> >>(Reverse address to reply.)
> >>
> >>
> >>
> >>
> >>"KenA" <KenA@.discussions.microsoft.com> wrote in message
> >>news:1354FE6C-F45A-4D01-A8CA-AFFB0073A6DC@.microsoft.com...
> >>
> >>Hi. In Access I can set a field as Boolean ... what´s the equivalent
for
> >>
> >>SqlServer?
> >>
> >>
> >>

No comments:

Post a Comment