zoukankan      html  css  js  c++  java
  • SQL 生成随机时间

    代码

     1 declare @id as nvarchar(36)
     2 declare @ctime as datetime
     3 declare   @starttime   datetime,     --开始时间   
     4                   @endtime       datetime       --结束时间 
     5 select     @starttime='1760-08-01   06:00:00',   
     6                   @endtime='2009-11-30   08:00:00'  
     7 
     8 set identity_insert tb_TestTable on 
     9 declare @count int 
    10 set @count=1
    11 while @count<=100
    12 begin 
    13 set @id=replace(newid(),'-','')
    14     
    15   select  @ctime= dateadd(   
    16                                   minute,   
    17                                   convert(int,(rand()*datediff(minute,@starttime,@endtime))),   
    18                                   @starttime   
    19                               )
    20     insert into funnytbl(id,userName,creattime) values
    21                        (@count,@id,@ctime
    22     set @count=@count+1 
    23 end 
    24 set identity_insert tb_TestTable off
  • 相关阅读:
    [luogu]P1852跳跳棋
    StdDraw绘图
    Java-Timer-Stop
    人之初
    单例模式--延时初始化
    ubuntu忘记密码
    QT5 TK1 串口通信
    金秋十月
    级联分类器训练-----OpenCV
    Hu矩SVM训练及检测-----OpenCV
  • 原文地址:https://www.cnblogs.com/smallfa/p/1866407.html
Copyright © 2011-2022 走看看