使用Case。 eg:Select (Case Sex When 0 Then N'男' Else N'女' End) As 性別 from tblStudent
select 转换后=case 字段名 when 1 then '是' else '否' end from 表名
在数据库中存放的是0/1/NULL,自己用SQL转:select case 字段 when 1 then '是' when 0 then '否' else '空' end from 表
create table #t(id int,fd bit)insert into #t(id,fd) values(1,1) insert into #t(id,fd) values(2,0) insert into #t(id,fd) values(3,3) --这里插入非0数据,自动转换为1select id,case fd when 1 then '是' else '否' end as 是否 from #t--orselect id,case when fd=1 then '是' else '否' end as 是否 from #tdrop table #t
eg:Select (Case Sex When 0 Then N'男' Else N'女' End) As 性別 from tblStudent
create table #t(id int,fd bit)insert into #t(id,fd) values(1,1)
insert into #t(id,fd) values(2,0)
insert into #t(id,fd) values(3,3) --这里插入非0数据,自动转换为1select id,case fd when 1 then '是' else '否' end as 是否 from #t--orselect id,case when fd=1 then '是' else '否' end as 是否 from #tdrop table #t