Generating Guid.Empty in SQL Server
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- | |
-- 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