Click here to Skip to main content
Click here to Skip to main content

How to get an empty GUID in SQL Server

By , 19 Apr 2011
 
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.

License

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

About the Author

nit_singh
Software Developer (Senior)
India India
No Biography provided

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
GeneralNicememberStark DaFixzer26-Apr-11 2:03 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

| Advertise | Privacy | Mobile
Web03 | 2.6.130731.1 | Last Updated 19 Apr 2011
Article Copyright 2011 by nit_singh
Everything else Copyright © CodeProject, 1999-2013
Terms of Use
Layout: fixed | fluid