65.9K
CodeProject is changing. Read more.
Home

How to get an empty GUID in SQL Server

starIconstarIconstarIconstarIcon
emptyStarIcon
starIcon

4.23/5 (9 votes)

Apr 18, 2011

CPOL
viewsIcon

120603

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
myValue = '00000000-0000-0000-0000-000000000000'
But instead of this, we can also do
select cast(cast(0 as binary) as uniqueidentifier)
and compare with this.