怎么使用T-sql生成两位字母

 SQL code

select char(cast(rand()*25 as int)+97)+char(cast(rand()*25 
            as int)+97) 

select 两位随机字母 = 
(select top 1 id from (select 'A' as id union select 'B' union select 'C' union select 'D' union select 'E' union select 'Z') m order by newid())
+
(select top 1 id from (select 'A' as id union select 'B' union select 'C' union select 'D' union select 'E' union select 'Z') n order by newid())

            范围为0-1的之间的float数。

            那么 * 25就得到 0 到 25之间的数。

            0-25之间的数 + 97 就得到 97-122之间的数。

            26个英文字母, a的ascii码是97


            你要产生的大写的话,写 + 65 就可以了。

原文地址:https://www.cnblogs.com/accumulater/p/6137243.html