1

我想删除表中 6 个字段的答案为零/空的行:

Delete
from TableA
WHERE (a + b + c + d + e + f) IS NULL

谢谢

4

4 回答 4

2
 WHERE COALESCE((a + b + c + d + e + f), 0) = 0

或者

 WHERE NULLIF((a + b + c + d + e + f), 0) IS NULL

不需要对每一列都有这个

于 2013-06-03T10:36:24.970 回答
1

尝试这个

DELETE T FROM
  dbo.TableA T
  WHERE COALESCE(a, 0) + 
        COALESCE(b, 0) + 
        COALESCE(c, 0) +
        COALESCE(d, 0) +
        COALESCE(e, 0) +
        COALESCE(f, 0) = 0

看到这个 SQLFiddle

于 2013-06-03T10:28:56.490 回答
0

如果您只想删除这些行,那么您可以使用查询

DELETE FROM TableName
WHERE (a + b + c + d + e + f) IS NULL OR (a + b + c + d + e + f) = 0

我希望它会帮助你。:)

于 2013-06-03T10:29:30.620 回答
0

您的意思是如果所有字段为空,或者如果 1 个或多个字段为空?

它可能很简单:

delete
from TableA
WHERE (a + b + c + d + e + f) IS NULL
于 2013-06-03T10:29:38.703 回答