生成时间序列有用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;--每次增加一秒 end
3.后记。
顺便说下生成随机数的方法:CAST(RAND()*100 AS int)