[英]select case when isnull('sdas',0)=0 then 'hi' else 'bye' end as 'Value'
The below query 下面的查询
select case when isnull('23',0)=0 then 'hi' else 'bye' end as 'Value'
returns bye
bye
BUT 但
select case when isnull('sdas',0)=0 then 'hi' else 'bye' end as 'Value'
returns the following Error message in MS-SqlServer2008R2 在MS-SqlServer2008R2中返回以下错误消息
Msg 245, Level 16, State 1, Line 1
Conversion failed when converting the varchar value 'sdas' to data type int.
Can you clarify it on which stage it gets conversion has been done 您能说明它在哪个阶段完成了转化
'23'
can be converted to int on the fly, but 'sdas'
don't. '23'
可以即时转换为int,但'sdas'
不能。 take string(varchar)-type for all variables: 对所有变量采用string(varchar)-type:
select case when isnull('sdas','0')='0' then 'hi' else 'bye' end as 'Value'
The problem is converting sdas
to an integer 0
. 问题是将sdas
转换为整数0
。 Instead of using the isnull
function, you could use the is null
operator: 可以使用is null
运算符来代替使用isnull
函数:
select case when 'sdas' is null then 'hi' else 'bye' end as 'Value'
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.