Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles / database / SQL-Server

How to get an empty GUID in SQL Server

4.23/5 (9 votes)
19 Apr 2011CPOL 120.6K  
A method of comparing with an empty GUID
Sometimes we need to compare a value with an empty GUID in SQL Server, and used to do something like
SQL
myValue = '00000000-0000-0000-0000-000000000000'


But instead of this, we can also do
SQL
select cast(cast(0 as binary) as uniqueidentifier)

and compare with this.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)