This will generate a random password with 4 random letters and two random numbers with numbers and letters in random locations, for a total of 6 characters from your allowed password charactersdeclare @pc table (PCHAR char(1) not null,SEQ int not null identity(1,1))insert into @pc (PCHAR)select top 100 percent PCHARfrom(select PCHAR = substring(STRING,(NUM%len(STRING))+1,1), seq1 = newid()from ( select STRING= 'ABCDEFHJKMNRSTUVWXYZ' ) A cross join ( select num = abs(convert(int,convert(varbinary(60),NI))) from ( select NI = newid() union all select NI = newid() union all select NI = newid() union all select NI = newid() ) bb ) bunion allselect PCHAR = substring(STRING,(NUM%len(STRING))+1,1), seq1 = newid()from ( select STRING = '23456789' ) A cross join ( select num = abs(convert(int,convert(varbinary(60),NI))) from ( select NI = newid() union all select NI = newid() ) bb ) b) cORDER BY seq1select NEW_PASSWORD = ( select PCHAR FROM @pc WHERE SEQ = 1 )+ ( select PCHAR FROM @pc WHERE SEQ = 2 )+ ( select PCHAR FROM @pc WHERE SEQ = 3 )+ ( select PCHAR FROM @pc WHERE SEQ = 4 )+ ( select PCHAR FROM @pc WHERE SEQ = 5 )+ ( select PCHAR FROM @pc WHERE SEQ = 6 )
Codo Ergo Sum