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

Tagged as

How to get an empty GUID in SQL Server

, 19 Apr 2011 CPOL
Rate this:
Please Sign up or sign in to vote.
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.

License

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

Share

About the Author

nit_singh
Software Developer (Senior)
India India
No Biography provided

Comments and Discussions

 
GeneralNice PinmemberStark DaFixzer26-Apr-11 3:03 
I love it , thank you
I know nothing , I know nothing ...

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

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

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