Skip to content

Instantly share code, notes, and snippets.

@brentmaxwell
Forked from jonsagara/EmptyGuid.sql
Created January 20, 2022 20:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save brentmaxwell/e294d40dfbb243a7ddd31950e61579af to your computer and use it in GitHub Desktop.
Save brentmaxwell/e294d40dfbb243a7ddd31950e61579af to your computer and use it in GitHub Desktop.
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