zoukankan      html  css  js  c++  java
  • sql随机产生姓名

    declare @firstNames varchar(max)    /* 保存名的集合 */
    declare @lastNames varchar(max)        /* 保存姓的集合 */

    set@firstNames='芳,海,亮,红,君,军,俊,江,河,湖,波,杰,山,燕,阳,洋,涛,斌,彬,宾,微,伟,威,薇,刚,倩'/* 必须只有一个字 */
    set @lastNames = '刘,方,王,李,赵,孙,钱,胡,易,黄,温,丁,周,魏,陈,曾,涂'    /* 必须只有一个字 */
    declare @lastNamesLength int
    declare @firstNamesLength int
    set @lastNamesLength = (LEN(@lastNames- 1/ 2 + 1
    set @firstNamesLength = (LEN(@firstNames- 1/ 2 + 1

    declare @firstNameRandom int
    declare @lastNameRandom int

    declare @resultFullNames varchar(max)
    set @resultFullNames = ''

    declare @i int
    set @i = 1
    while(@i <= 1000)
    begin
        set @firstNameRandom = CEILING(rand()*@firstNamesLength)
        set @lastNameRandom = CEILING(rand()*@lastNamesLength)
        /*
            产生第 1 个字,对于的 Index 为 1,注意:这里的 Index 最小值为 1。
            产生第 2 个字,对于的 Index 为 3,
            产生第 3 个字,对于的 Index 为 5,
            ...
        
    */
        set @resultFullNames = @resultFullNames + ( SUBSTRING(@lastNames@lastNameRandom * 2 - 11+ SUBSTRING(@firstNames@firstNameRandom * 2 - 11+ ',' )
        set @i = @i + 1
    end
    print @resultFullNames

  • 相关阅读:
    PPT图片
    饥荒Steam相关mod代码
    Ubuntu20.04更换阿里源 source.list文件
    中断处理与进程调度的区别与联系
    原语和系统调用的区别
    立下个flag,这个月底之前要发一个深度学习入门系列的文章
    conda安装skimage
    机器学习入门(三)
    zip安装的MySQL绑定my.ini配置文件
    Anaconda配置安装
  • 原文地址:https://www.cnblogs.com/AngelLee2009/p/2229716.html
Copyright © 2011-2022 走看看