zoukankan      html  css  js  c++  java
  • 怎么使用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 就可以了。

  • 相关阅读:
    Mybatis+Spring整合
    java 线程详解
    java 异常处理
    java 日期 时间操作
    RandomAccessFile 详解
    js导入excel
    java 常见异常
    常用的java程序片段(算法)
    IO流详解
    json 详解
  • 原文地址:https://www.cnblogs.com/accumulater/p/6137243.html
Copyright © 2011-2022 走看看