Bit 判断男女解决方案

Bit 判断男女create table aa(Sid int not null primary key,name char(8) not null ,sex bit ?)请问在字

Bit 判断男女
create table aa
(Sid int not null primary key,
name char(8) not null ,
sex bit ?
)
请问在字段sex 那里怎么定义当 1:男 0:女

[解决办法]
bit就两个值:1和0,你怎么定义男女??
你可以查询的时候用case when then else end来判断
[解决办法]

只能在查询的时候定义
select case when sex=1 then '男' else '女' end 性别 from aa

[解决办法]
在程序里判断的。


select case sex when 1 then '男' when 0 then '女' end as 性别 from #aa
[解决办法]

SQL code
select case when sex=1 then '男' else '女' end 性别 from aa
[解决办法]
晕,1和0不要硬性指定,在程序端或者sql语句查询的时候才解释出来。不然你使用bit就没有意义了。