TypeId implementation in pure T-SQL.
Directly run the content of typeid_tsql on your server.
Regenerate the SQL by yourself using the script ./build.sh
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 |
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.