检查 SQL Server 2005 XML 字段是否为空

发布于 2024-09-07 09:03:44 字数 293 浏览 8 评论 0原文

我只是这样做:

Delete FROM MyTable WHERE ScopeValue = "" 
Delete FROM G_Scope WHERE ScopeValue is ''
Delete FROM G_Scope WHERE ScopeValue = empty
Delete FROM G_Scope WHERE ScopeValue is empty

我想删除具有 xml 字段(不可为空)的所有行,其中 ScopeValue 列具有空条目意味着零个字符。

有人知道吗?

I just did this:

Delete FROM MyTable WHERE ScopeValue = "" 
Delete FROM G_Scope WHERE ScopeValue is ''
Delete FROM G_Scope WHERE ScopeValue = empty
Delete FROM G_Scope WHERE ScopeValue is empty

I want to delete all rows with xml field (not nullable) where ScopeValue column has empty entries means zero chars.

Anyone knows?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

一萌ing 2024-09-14 09:03:44

试试这个:

 DELETE FROM dbo.G_Scope WHERE ScopeValue IS NULL

如果不包含任何值,SQL Server 列将为 NULL

另一种可能性是 XML 不为 NULL,但包含空字符串作为其值。为此,请使用以下命令:

-- The DATALENGTH of an empty XML column is 5
SELECT * FROM dbo.G_Scope WHERE DATALENGTH(ScopeValue) = 5

这会显示您感兴趣的行吗?

Try this:

 DELETE FROM dbo.G_Scope WHERE ScopeValue IS NULL

The SQL Server column would be NULL is if contains no value.

The other possibility would be that the XML is not NULL, but contains an empty string as its value. For that, use this command:

-- The DATALENGTH of an empty XML column is 5
SELECT * FROM dbo.G_Scope WHERE DATALENGTH(ScopeValue) = 5

Does that show you the rows you're interested in?

安穩 2024-09-14 09:03:44

这对我有用:

DELETE FROM MyTable
WHERE ScopeValue.exist('/node()') = 1;

This works for me:

DELETE FROM MyTable
WHERE ScopeValue.exist('/node()') = 1;
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文