This file contains hidden or 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
CREATE FUNCTION [dbo].[GenerateULID] | |
( | |
@random AS BINARY(10), | |
@timestamp AS DATETIME2 = NULL | |
) | |
RETURNS VARCHAR(26) | |
AS | |
BEGIN | |
-- Crockford's base32 alphabet | |
DECLARE @alphabet VARCHAR(32) = '0123456789ABCDEFGHJKMNPQRSTVWXYZ' |