Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
TSQL - Globally unique string generator
Language:
Ada
Assembly
Bash
C#
C++ (gcc)
C++ (clang)
C++ (vc++)
C (gcc)
C (clang)
C (vc)
Client Side
Clojure
Common Lisp
D
Elixir
Erlang
F#
Fortran
Go
Haskell
Java
Javascript
Kotlin
Lua
MySql
Node.js
Ocaml
Octave
Objective-C
Oracle
Pascal
Perl
Php
PostgreSQL
Prolog
Python
Python 3
R
Rust
Ruby
Scala
Scheme
Sql Server
Swift
Tcl
Visual Basic
Layout:
Vertical
Horizontal
declare @characterPool varchar(256) = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; declare @outputLength int = 32; declare @n int = 0; /* counter */ declare @numLoops int = ceiling(log(len(@characterPool)) / log(2) * @outputLength / 128) declare @e varbinary(128) = 0x; /* entropy */ while @n < @numLoops begin set @e += cast(newid() as binary(16)); set @n += 1; end declare @b int; /* byte */ declare @d int; /* dividend */ declare @out varchar(128) = ''; declare @outputBase int = len(@characterPool); declare @entropyBytes int = len(@e); declare @m int = 0; while @m < @outputLength begin set @b = 0; set @d = 0; set @n = 0; while @n < @entropyBytes /* big-endian */ begin set @b = (@b - @d * @outputBase) * 256 + cast(substring(@e, @n + 1, 1) as int); set @d = @b / @outputBase; set @e = cast(stuff(@e, @n + 1, 1, cast(@d as binary(1))) as varbinary(128)); set @n += 1; end set @out = substring(@characterPool, @b - @d * @outputBase + 1, 1) + @out; set @m += 1; end select @out as "UniqueString"
View schema
Execution time: 0,03 sec, rows selected: 4270, rows affected: 0, absolute service time: 0,19 sec
edit mode
|
history
|
discussion
UniqueString
1
pqpPMgWTxzVbwLuuSefRWISWfSUZmSPC