select Random_String = substring(x,(abs(checksum(newid()))%36)+1,1)+ substring(x,(abs(checksum(newid()))%36)+1,1)+ substring(x,(abs(checksum(newid()))%36)+1,1)+ substring(x,(abs(checksum(newid()))%36)+1,1)+ /* and so on for as many characters as needed */ substring(x,(abs(checksum(newid()))%36)+1,1)from (select x='0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ') a Results: Random_String-------------T7TAR
witha1 as (select 1 as N union all select 1 union all select 1 union all select 1 union all select 1 union all select 1 union all select 1 union all select 1 union all select 1 union all select 1),a2 as (select 1 as N from a1 as a cross join a1 as b),a3 as (select 1 as N from a2 as a cross join a2 as b),a4 as (select 1 as N from a3 as a cross join a2 as b),Tally as (select row_number() over (order by N) as N from a4), cteRandomString ( RandomString) as (select top (64) substring(x,(abs(checksum(newid()))%36)+1,1)from Tally cross join (select x='0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ') a)selectreplace((select ',' + RandomStringfrom cteRandomStringfor xml path ('')),',','');