58 lines
1.8 KiB
Markdown
Executable File
58 lines
1.8 KiB
Markdown
Executable File
rollback
|
|
commit
|
|
begin tran
|
|
|
|
```sql
|
|
declare @x numeric(18,2) --X
|
|
declare @dt datetime --时间
|
|
declare @gpsindex numeric(18,2) --GPSIndex
|
|
declare @rand float --随机数
|
|
declare @count int --计数
|
|
|
|
set @x = 0
|
|
set @count = 1
|
|
set @dt = '2018-09-01 18:35:00'
|
|
|
|
```
|
|
while(@dt < getdate()) begin
|
|
|
|
-- set @gpsindex = convert(bigint, datediff(ss, '1970-01-01 00:00:00', @dt))*1000 + datepart(ms,@dt)
|
|
|
|
|
|
```sql
|
|
declare @SELECT_SQL1 NVARCHAR(500)
|
|
declare @GPSINDEX1 bigint
|
|
declare @utcnow1 datetime
|
|
declare @adatetime1 datetime
|
|
declare @X1 float
|
|
declare @Y1 float
|
|
declare @H1 float
|
|
declare @DX1 float
|
|
declare @DY1 float
|
|
declare @DH1 float
|
|
|
|
SET @SELECT_SQL1 = 'SELECT TOP 1 @X1=T.[X],@Y1 = T.[Y],@H1=T.[Height],@DX1=T.[dltaX],@DY1=T.[dltaY],@DH1=T.[dltaH] FROM [HMProject].[dbo].[SongZi2_RTK] AS T order by ADATETIME desc'
|
|
|
|
EXEC sp_executesql @SELECT_SQL1, N'@X1 float out,@Y1 float out,@H1 float out,@DX1 float out,@DY1 float out,@DH1 float out',@X1 out,@Y1 out,@H1 out,@DX1 out,@DY1 out,@DH1 out
|
|
|
|
SET @utcnow1 = GETDATE()
|
|
SET @GPSINDEX1 = (cast(datediff(ss,'1970-01-01',@dt) as bigint)*1000) - ((DateName(minute,@utcnow1))%10)*60000 - DateName(second,@utcnow1)*1000
|
|
SET @X1 = @X1+ (rand()*-1 + 0.501)/2000 SET @Y1 = @Y1+ (rand()*-1 + 0.501)/2000 SET @H1 = @H1+ (rand()*-1 + 0.499)/2000 SET @DX1 = @DX1+ rand()/99 SET @DY1 = @DY1+ rand()/99 SET @DH1 =
|
|
|
|
```
|
|
@DH1+ rand()/99
|
|
```sql
|
|
SET @adatetime1 = DATEADD(S,@GPSINDEX1/1000,'1970-01-01 00:00:00')
|
|
|
|
BEGIN TRY insert into [HMProject].[dbo].[SongZi2_RTK]([GPSIndex],[aDatetime],[X],[Y],[Height],[dltaX],[dltaY],[dltaH])VALUES(@GPSINDEX1,@adatetime1,@X1,@Y1,@H1,@DX1,@DY1,@DH1) END TRY BEGIN
|
|
|
|
```
|
|
CATCH END CATCH
|
|
|
|
--insert into [ZHDMTProj].[dbo].[Flowmeter01]([GPSIndex],[aDatetime],[X]) values(@gpsindex, @dt, @x) --目标表
|
|
--****************
|
|
```sql
|
|
set @count = @count + 1
|
|
set @dt = DATEADD(MI,5,@dt) --每次递增5 min
|
|
```
|
|
end |