Skip to content

Instantly share code, notes, and snippets.

@ppolyzos
Created January 12, 2016 08:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ppolyzos/df6d77360732a3c68106 to your computer and use it in GitHub Desktop.
Save ppolyzos/df6d77360732a3c68106 to your computer and use it in GitHub Desktop.
TSQL: Generate Random String of desired length
DECLARE @DesiredLength AS INT = 10;
select Lower(substring(replace(newID(), '-', ''), cast(RAND() * (31 - @DesiredLength) AS INT),
@DesiredLength)) AS randomString;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment