sql server 7 data type "BIT"

sql server 7 data type "BIT"

Post by Tomca » Sat, 24 Nov 2001 14:01:34



when i set data type ,which is bit, in  SQL server , then the "-1" will show
on datagird
how can i show the correct value "1" in datagrid?

if not in datagird, abs(cint(rs.field("bit_field"))) is ok...
but how it works in datagird?

 
 
 

sql server 7 data type "BIT"

Post by Narayana Vyas Kondredd » Tue, 27 Nov 2001 01:02:42


Where is this data grid? Are you talking about a VB application with a data
grid? VB interprets True as -1.
--
HTH,
Vyas,
SQL Server FAQ, articles, code samples,

http://vyaskn.tripod.com/


Quote:> when i set data type ,which is bit, in  SQL server , then the "-1" will
show
> on datagird
> how can i show the correct value "1" in datagrid?

> if not in datagird, abs(cint(rs.field("bit_field"))) is ok...
> but how it works in datagird?


 
 
 

1. type "bit", what to input?


|>
|> Dear experts,
|>
|> I declared a column with type bit (boolean), because I just want to store
|> information like "yes" or "no". But what should I input into that field
|> in my SQL statement?
|>

Bit takes numerical values (int, float, numeric, decimal, etc.), but  
it stores only zeros and ones.  Any value x that is inserted will
be stored as a 0 if -1 < x < 1.  
All other values will be stored as a 1.

Example:
create table bit_test (x bit, y numeric(20,10))
go
insert bit_test values (100,100)
insert bit_test values (1,1)
insert bit_test values (0.9,0.9)
insert bit_test values (0.1,0.1)
insert bit_test values (0,0)
insert bit_test values (-0.1,-0.1)
insert bit_test values (-0.9,-0.9)
insert bit_test values (-0.99999,-0.99999)
insert bit_test values (-1,-1)
insert bit_test values (-100,-100)
go
select * from bit_test
go
drop table bit_test
go
  x   y                    
 --- --------------------
   1           100.000000
   1             1.000000
   0             0.900000
   0             0.100000
   0             0.000000
   0            -0.100000
   0            -0.900000
   0            -0.999990
   1            -1.000000
   1          -100.000000

(10 rows affected)

--
---------------------------------------------------------------------

| Sybase Technical Support                                    __|
| 6475 Christie Avenue                                       |__
| Emeryville, CA 94608 USA                                      |___
| fax: (510)-922-3911              exec sp_realitycheck()           |
#####################################################################

2. Importing Data

3. Type "Image" in SQl Server 7

4. Incremental retrieval from a huge DB

5. MS SQL Server 7 and "uniqueidentity"-type columns

6. Backup Restore Problems

7. max of ("...","...","..")

8. preserving sort order

9. Problem with "image" data type

10. Best data type for "Description" field

11. Example with data type "Table"

12. Problem with "image" data type