随机时间

declare @i int
declare @time varchar(50)
set @i=1
set @time='2014-12-19' --年月日
while @i<12
begin
insert into datetimes(time,datetime,state)values(@time,DATEADD(MILLISECOND,ABS(CHECKSUM(NEWID()))%DATEDIFF(MILLISECOND,@time,@time+' 23:59:59.000'),@time),0)
set @i=@i+1
end
delete datetimes

你可能感兴趣的:(时间)