1

我有一些 gps lat lng 点与,其中一些分开

  28.964783549308777,41.00934982475349,0
  28.964102268218994,41.00941054477526,0
  28.9627343416214,41.00958865651625,0
  28.96224081516266,41.00963318437629,0
  28.961591720581055,41.0096412803476,0

我有大约 1K 行。(我可以删除,0它不需要)

我的专栏有 lat、lng、date、speed。我想用这个 lat lng 添加它们,并随机增加时间和随机速度。

第一个时间示例是 2013-10-21 12:03:20 第二个 2013-10-21 12:03:23 第三个 2013-10-21 12:03:25。秒必须随机增加 2 到 5 秒。

速度必须在 20 到 35 之间完全随机变化。

如何将它们全部组合并自动插入?

4

1 回答 1

0
DECLARE @StartDate datetime = GETDATE()

;with dt as (
SELECT CAST(1 as int) as ID, @StartDate as dtime,CAST(20+ROUND(15*RAND(CHECKSUM(NEWID())),0) as int) as speed
UNION ALL
SELECT ID + 1, DATEADD(SECOND,2+ROUND(3*RAND(CHECKSUM(NEWID())),0),dtime) , CAST(20+ROUND(15*RAND(CHECKSUM(NEWID())),0) as int)
FROM dt
WHERE ID <= 1000)

SELECT *
FROM dt
OPTION (MAXRECURSION 0);
GO
于 2013-10-21T13:33:27.153 回答