如何在 SQL Server 2005 中识别空白的 uniqueidentifier?
我将一个 uniqueidentifier
放入一个看起来像这样
00000000-0000-0000-0000-000000000000
的存储过程中。
这看起来很简单,但是如何识别这是一个空白的uniqueidentifier
呢?
如果我得到这样的值 DDB72E0C-FC43-4C34-A924-741445153021
我想做 X
如果我得到这样的值 00000000-0000-0000-0000-000000000000
> 我做 Y
有没有比计算零更优雅的方法?
提前致谢
I'm getting a uniqueidentifier
into a Stored Procedure that looks like this
00000000-0000-0000-0000-000000000000
.
This seems like a simple thing, but how can identify that this is a blank uniqueidentifier
?
If I get a value like this DDB72E0C-FC43-4C34-A924-741445153021
I want to do X
If I get a value like this 00000000-0000-0000-0000-000000000000
I do Y
Is there a more elegant way then counting up the zeros?
Thanks in advance
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
比较
?
compare to
?
只需创建一个 EmptyGuid 变量并与之比较:
Just create an EmptyGuid variable and compare against that:
最好的解决方案是对空 GUID 使用常量
,或者
您只需比较它们
注意:您不需要使用强制转换和转换
Best solution is to use a constant for the empty GUID
OR
and you just compare them
Note: you don't need to use casts and converts
这也有效。
This also works.