【SQL Server 学习系列】-- 随机生成日期时间的SQL脚本
1 DECLARE @dt1 DATETIME,@dt2 DATETIME,@a BIGINT,@b BIGINT 2 SET @dt1='2010-01-01'--开始日期 3 SET @dt2='2010-06-30'--结束日期 4 5 SELECT @a=CAST(@dt1 AS BIGINT),@b=CAST(@dt2-@dt1 AS BIGINT) 6 7 SELECT CAST(ABS(CHECKSUM(newID()))%@b+@a AS DATETIME)+RAND() AS 日期