--循环插入一年的时间DROP TABLE #tempCREATE TABLE #temp (date DATETIME); DECLARE @year INTSET @year=2019;WITH a1 AS(SELECT CAST(RTRIM(@year)+'-01-01' AS DATETIME) dateUNION ALLSELECT DATEADD(dd,1,date) FROM a1 WHERE DATEPART(yy,DATEADD(dd,1,date))=@year)INSERT #tempSELECT date FROM a1 EXCEPT SELECT date FROM #tempOPTION(MAXRECURSION 0)--sql 一定范围随机数CAST((rand()*300+ 100) as dec(10,0)) --sql 循环declare @carID DECIMALset @carID=0 while @carID<24begin--INSERT INTO EM_RegionEnergyConsumption VALUES(10,CONVERT(varchar(100), GETDATE(), 23),@Result1 )set @carID=@carID+1END