Skip to content

Instantly share code, notes, and snippets.

@brentmaxwell
Forked from jonsagara/EmptyGuid.sql
Created January 20, 2022 20:42
Embed
What would you like to do?
Generating Guid.Empty in SQL Server
--
-- 2021-11-24: suggestion from comments:
--
DECLARE @EmptyEmpty UNIQUEIDENTIFIER = CAST(0x0 AS UNIQUEIDENTIFIER)
SELECT @EmptyEmpty
--
-- Original
--
DECLARE @EmptyGuid UNIQUEIDENTIFIER
SET @EmptyGuid = (SELECT CAST(CAST(0 AS BINARY) AS UNIQUEIDENTIFIER))
-- Single result is 00000000-0000-0000-0000-000000000000
SELECT @EmptyGuid
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment