c# sql

The empty Guid

This is a neat trick I had to google for quite some time to find.
Now I’m saving it here to never have to search for it again!

Occasionally I’ve had to create an empty Guid in T-SQL and to do so I’ve done weird things like writing a statement like this:


Copy/Paste the results into the editor and then replace every single letter with a zero.

There is, of course, an easier way to do this and it’s kinda like the Guid.Empty property you can use in C#¬†and it goes something like this:

SELECT CAST(0x0 AS uniqueidentifier)

It’s that simple.