Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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

like image 482
codingguy3000 Avatar asked Dec 18 '09 22:12

codingguy3000


People also ask

Can Uniqueidentifier be null in SQL?

You can make uniqueidentifiers null.

How do I find unique identifier in SQL?

In SQL Server, you can use the sp_special_columns system stored procedure to identify a unique identifier for the table. Specifically, it returns the optimal set of columns that uniquely identify a row in the table. It also returns columns automatically updated when any value in the row is updated by a transaction.

What is the Uniqueidentifier datatype in SQL?

The globally unique identifier (GUID) data type in SQL Server is represented by the uniqueidentifier data type, which stores a 16-byte binary value. A GUID is a binary number, and its main use is as an identifier that must be unique in a network that has many computers at many sites.


1 Answers

compare to

cast(cast(0 as binary) as uniqueidentifier)

?

like image 53
davek Avatar answered Nov 14 '22 23:11

davek