小弟建立了一个字段content是ntext类型,现在想统计有多少记录是没有数据的.
在查询分析器里,用了SELECT count(*)  FROM article WHERE  content=''语句
结果说要"不能比较或排序 text、ntext 和 image 数据类型,除非使用 IS NULL 或 LIKE 运算符。"
我后来使用SELECT count(*)  FROM article WHERE  content is null 语句,显示的结果始终是0
希望大家能指点我如何得到正确的结果.



如果content里的值为null,不是空值。
这样是可以查出来的
SELECT count(*)  FROM article WHERE  content is null
反之,则这样:
SELECT count(*)  FROM article WHERE  Isnull(content,'') like ''
SELECT count(*)  FROM article WHERE  datalength(Isnull(content,''))=0
这样也行.

相关文章:

  • 2021-09-21
  • 2022-01-07
  • 2021-05-31
  • 2021-08-29
  • 2022-02-23
  • 2021-06-27
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-01-12
  • 2022-12-23
  • 2022-03-05
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案