Skip to content

uniteeio/typeid_tsql

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

TypeId T-SQL (SQL Server)

TypeId implementation in pure T-SQL.

Install / Generate

Directly run the content of typeid_tsql on your server.

Regenerate the SQL by yourself using the script ./build.sh

Usage

CREATE TABLE MyTable (
    Id VARCHAR(90) NOT NULL DEFAULT dbo.typeId_NewTypeId('test'),
    Label VARCHAR(100)
)
GO

INSERT INTO MyTable (Label) VALUES ('new label')
GO

SELECT Id, Label, dbo.typeId_Decode(Id) AS DecodedUID FROM MyTable
GO
Id Label DecodedUID
test_069t2trynchwpq50001pqtwnpy new label 064e85ac-7aac-8f2d-7280-000dafae56de

Caveat

It's not possible to generate a sub-millisecond timestamp in T-SQL. Thus, we generated the timestamp using a millisecond unix timestamp combined with random data. That means that two typeid generated in the same millisecond won't be k-sortable.

I believe that it would be possible to combine the timestamp with a number coming from a Sequence to preserve the sequentiality and concurrency.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published