sqlserver2005生成时间递增序列,用于批量生成数据,测试等。
发布时间:2020-12-12 13:38:17 所属栏目:MsSql教程 来源:网络整理
导读:1.前言。 ? 生成时间序列有用convert时间拼接的,但用dateadd比较方便。代码如下: 2.代码。 DECLARE @t datetime;DECLARE @v_count int;SET @t='2011-3-11 09:50:42';SET @v_count=0;while @v_count100begin SET @t=DATEADD(ss,@v_count); set @v_count=@v_
1.前言。
? 生成时间序列有用convert时间拼接的,但用dateadd比较方便。代码如下: 2.代码。 DECLARE @t datetime; DECLARE @v_count int; SET @t='2011-3-11 09:50:42'; SET @v_count=0; while @v_count<100 begin SET @t=DATEADD(ss,@v_count); set @v_count=@v_count+1;--每次增加一秒 end3.后记。 顺便说下生成随机数的方法:CAST(RAND()*100 AS int) (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |