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

Tagged as

Go to top

How to get an empty GUID in SQL Server

, 19 Apr 2011
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 2:03 

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 | Mobile
Web01 | 2.8.140916.1 | Last Updated 19 Apr 2011
Article Copyright 2011 by nit_singh
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid