|
Home > Archive > microsoft.public.sqlserver.server > December 2002 > Binary Data Type
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
|
|
| Joe Mumbauer 2002-12-19, 3:23 pm |
| I am using ASP to connect to an SQL Server 7 database. I basically want to have
a list of bits to use as flags. An integer is too small, and so I thought
binary would work. The only problem is I'm not sure how to access the data.
It's giving me a type mismatch error when I try to access the value.
How do you access a variable of type binary? Also, is there a better way to do
what I'm trying to do? I don't want to use varchar, because that uses an entire
byte for each character. Any suggestions would be appreciated.
Thanks,
Joe Mumbauer.
| |
| Russell Fields 2002-12-19, 3:23 pm |
| Joe,
Have you tried using BIT instead of BINARY?
Russell Fields
"Joe Mumbauer" <mumb1803@kutztown.edu> wrote in message
news:O9BYb25pCHA.2764@TK2MSFTNGP09...
> I am using ASP to connect to an SQL Server 7 database. I basically want
to have
> a list of bits to use as flags. An integer is too small, and so I thought
> binary would work. The only problem is I'm not sure how to access the
data.
> It's giving me a type mismatch error when I try to access the value.
> How do you access a variable of type binary? Also, is there a better way
to do
> what I'm trying to do? I don't want to use varchar, because that uses an
entire
> byte for each character. Any suggestions would be appreciated.
> Thanks,
>
> Joe Mumbauer.
>
>
| |
| bruce barker 2002-12-19, 4:24 pm |
| to access the bits in a binary field, pluck a chuck of it an d convert to
int, which you can then do bit test. do reverse to set.
declare @b binary(4)
declare @bitnumber int
set @b = 0x01020304
set @bitnumber = 10 -- test bit if 0x0002 set
select
case
when cast(substring(@b, (@bitnumber / 8) + 1,1) as int) &
(@bitnumber % 8) <> 0 then 1
else 0
end as BitSet
-- bruce (sqlwork.com)
"Joe Mumbauer" <mumb1803@kutztown.edu> wrote in message
news:O9BYb25pCHA.2764@TK2MSFTNGP09...
> I am using ASP to connect to an SQL Server 7 database. I basically want
to have
> a list of bits to use as flags. An integer is too small, and so I thought
> binary would work. The only problem is I'm not sure how to access the
data.
> It's giving me a type mismatch error when I try to access the value.
> How do you access a variable of type binary? Also, is there a better way
to do
> what I'm trying to do? I don't want to use varchar, because that uses an
entire
> byte for each character. Any suggestions would be appreciated.
> Thanks,
>
> Joe Mumbauer.
>
>
| |
| Joe Mumbauer 2002-12-19, 6:23 pm |
| I don't know how to have an array of bits...when I try to give a size for bit,
it says you can't allocate a size for that datatype.
Joe Mumbauer.
"Russell Fields" <rlfields@sprynet.com> wrote in message
news:OE3uAM6pCHA.1624@TK2MSFTNGP12...
> Joe,
>
> Have you tried using BIT instead of BINARY?
>
> Russell Fields
> "Joe Mumbauer" <mumb1803@kutztown.edu> wrote in message
> news:O9BYb25pCHA.2764@TK2MSFTNGP09...
> > I am using ASP to connect to an SQL Server 7 database. I basically want
> to have
> > a list of bits to use as flags. An integer is too small, and so I thought
> > binary would work. The only problem is I'm not sure how to access the
> data.
> > It's giving me a type mismatch error when I try to access the value.
> > How do you access a variable of type binary? Also, is there a better way
> to do
> > what I'm trying to do? I don't want to use varchar, because that uses an
> entire
> > byte for each character. Any suggestions would be appreciated.
> > Thanks,
> >
> > Joe Mumbauer.
> >
> >
>
>
| |
| Joe Mumbauer 2002-12-19, 6:23 pm |
| Is there a way to return the entire binary chunk to an ASP page, and then access
it in ASP? I know how to check for bits and all, but I just can't seem to
figure out how to get the data itself. Keeps giving me this type mismatch
error.
Thanks,
Joe Mumbauer.
"bruce barker" <nospam_brubar@safeco.com> wrote in message
news:egodYp6pCHA.704@TK2MSFTNGP09...
> to access the bits in a binary field, pluck a chuck of it an d convert to
> int, which you can then do bit test. do reverse to set.
>
> declare @b binary(4)
> declare @bitnumber int
> set @b = 0x01020304
> set @bitnumber = 10 -- test bit if 0x0002 set
> select
> case
> when cast(substring(@b, (@bitnumber / 8) + 1,1) as int) &
> (@bitnumber % 8) <> 0 then 1
> else 0
> end as BitSet
>
> -- bruce (sqlwork.com)
>
>
>
> "Joe Mumbauer" <mumb1803@kutztown.edu> wrote in message
> news:O9BYb25pCHA.2764@TK2MSFTNGP09...
> > I am using ASP to connect to an SQL Server 7 database. I basically want
> to have
> > a list of bits to use as flags. An integer is too small, and so I thought
> > binary would work. The only problem is I'm not sure how to access the
> data.
> > It's giving me a type mismatch error when I try to access the value.
> > How do you access a variable of type binary? Also, is there a better way
> to do
> > what I'm trying to do? I don't want to use varchar, because that uses an
> entire
> > byte for each character. Any suggestions would be appreciated.
> > Thanks,
> >
> > Joe Mumbauer.
> >
> >
>
>
| |
| bruce barker 2002-12-19, 6:23 pm |
| on the client side, its a SqlBinary which converts nicely to byte[] , which
oldly enough uses the same formula for testing a bit.
-- bruce (sqlwork.com)
"Joe Mumbauer" <Free@Bad-Candy.com> wrote in message
news:eUHMzZ7pCHA.2252@TK2MSFTNGP12...
> Is there a way to return the entire binary chunk to an ASP page, and then
access
> it in ASP? I know how to check for bits and all, but I just can't seem to
> figure out how to get the data itself. Keeps giving me this type mismatch
> error.
> Thanks,
>
> Joe Mumbauer.
>
>
> "bruce barker" <nospam_brubar@safeco.com> wrote in message
> news:egodYp6pCHA.704@TK2MSFTNGP09...
> > to access the bits in a binary field, pluck a chuck of it an d convert
to
> > int, which you can then do bit test. do reverse to set.
> >
> > declare @b binary(4)
> > declare @bitnumber int
> > set @b = 0x01020304
> > set @bitnumber = 10 -- test bit if 0x0002 set
> > select
> > case
> > when cast(substring(@b, (@bitnumber / 8) + 1,1) as int) &
> > (@bitnumber % 8) <> 0 then 1
> > else 0
> > end as BitSet
> >
> > -- bruce (sqlwork.com)
> >
> >
> >
> > "Joe Mumbauer" <mumb1803@kutztown.edu> wrote in message
> > news:O9BYb25pCHA.2764@TK2MSFTNGP09...
> > > I am using ASP to connect to an SQL Server 7 database. I basically
want
> > to have
> > > a list of bits to use as flags. An integer is too small, and so I
thought
> > > binary would work. The only problem is I'm not sure how to access the
> > data.
> > > It's giving me a type mismatch error when I try to access the value.
> > > How do you access a variable of type binary? Also, is there a better
way
> > to do
> > > what I'm trying to do? I don't want to use varchar, because that uses
an
> > entire
> > > byte for each character. Any suggestions would be appreciated.
> > > Thanks,
> > >
> > > Joe Mumbauer.
> > >
> > >
> >
> >
>
>
|
|
|
|
|