Generate Dynamic AlphaNumeric Values in SQL Server


declare @AuthKey varchar(255)
set @AuthKey = ''
select @AuthKey = @AuthKey + char(n) from
(
    select top 15 number as n
    from master..spt_values
    where type= 'p' and (
            (number between 48 and 57)  -- numbers
      or    (number between 65 and 90)  -- uppercase letters
      or    (number between 97 and 122) -- lowercase letters
    )
    order by newid()
) as t
print @AuthKey

Comments

Popular posts from this blog

How to Stop Excel from giving a number in scientific notation

The 'Microsoft.Jet.OLEDB.4.0' provider is not registered on the local machine

System.IO.IsolatedStorage.IsolatedStorageException: Unable to create the store directory