How do I identify a blank uniqueidentifier in SQL Server 2005?

codingguy3000 picture codingguy3000 · Dec 18, 2009 · Viewed 13.4k times · Source

I'm getting a uniqueidentifier into a Stored Procedure that looks like this

00000000-0000-0000-0000-000000000000.

This seems like a simple thing, but how can identify that this is a blank uniqueidentifier?

If I get a value like this DDB72E0C-FC43-4C34-A924-741445153021 I want to do X

If I get a value like this 00000000-0000-0000-0000-000000000000 I do Y

Is there a more elegant way then counting up the zeros?

Thanks in advance

Answer

davek picture davek · Dec 18, 2009

compare to

cast(cast(0 as binary) as uniqueidentifier)

?