日期:2014-05-18  浏览次数:20939 次

SQLSERVER的REPLACE方法
求解答如何同时替换字段中的两个值?

例如:

select ID,Content,IsEnabled from tb_Test

其中IsEnabled是bit类型字段

我想在显示的时候显示出来的是 启用 or 不启用

使用Replace方法只能处理0,1其中一个值

不要说让我在程序中判断

这个在查出来之后直接保存到DataSet中,并作为数据源直接绑定到DataGridView控件中

通常绑定之后DataGridView显示出来的是数字0 OR 1很影响用户体验

------解决方案--------------------
select case IsEnabled when 1 then '启用' else '不启用' end as IsEnabled
------解决方案--------------------
Select id,Content,case when isEnabled=1 then '启用' else '不启用' end IsEnabled
From tb_Test
------解决方案--------------------
select ID,Content, 
case IsEnabled 
when 0 then '启用'
when 1 then '不启用'
else IsEnabled 
end
from tb_Test
------解决方案--------------------
探讨
select case IsEnabled when 1 then '启用' else '不启用' end as IsEnabled

------解决方案--------------------
select ID,Content,case IsEnabled when 1 then '启用' else '不启用' end as IsEnabled from tb_Test

------解决方案--------------------
update的时候就正常操作就可以了,改成0或1均可
------解决方案--------------------
探讨

请问各位 - - 那UPDATE的时候呢……