SQL Isnull 不起作用并返回一个值,即使它是一个空格 [英] SQL Isnull is not working and returns a value even if it is a space

查看:42
本文介绍了SQL Isnull 不起作用并返回一个值,即使它是一个空格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的是 SQL Server 2016,但遇到了 isnull 函数的问题.该字段中的值是一个空格但一直被选中,下面是我的代码:

I am using SQL Server 2016 and came across an issue with the isnull function. The value in that field is a space but keeps getting selected, below is my code:

SELECT * FROM table
WHERE  isnull (field1,'')<>''
       AND field1<>' '

如果我从 field1 复制粘贴,它是一个空格 ' '.

If I copy and paste from field1, it is one space ' '.

谢谢

推荐答案

你的空间不是普通空间(十六进制0x20,十进制32)

Your space is not normal space (hex 0x20, decimal 32)

select ASCII(LEFT(field1, 1), * From table
where  isnull (field1,'')<>''

很可能是其中之一

  • 换行十进制 10
  • 回车十进制 13
  • 空十进制 0
  • 硬空间十进制 160
  • tab 十进制 9(根据@SeanLange 对问题的评论)

这篇关于SQL Isnull 不起作用并返回一个值,即使它是一个空格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆