Update from Sync Service
This commit is contained in:
26
数据库/循环遍历插数据.md
Executable file
26
数据库/循环遍历插数据.md
Executable file
@@ -0,0 +1,26 @@
|
||||
```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-07-02 12:00:00'
|
||||
|
||||
```
|
||||
while(@dt < getdate()) begin
|
||||
|
||||
```sql
|
||||
set @gpsindex = convert(bigint, datediff(ss, '1970-01-01 00:00:00', @dt))*1000 + datepart(ms,@dt)
|
||||
|
||||
|
||||
insert into [ZHDMTProj].[dbo].[Flowmeter01]([GPSIndex],[aDatetime],[X]) values(@gpsindex, @dt, @x) --目标表
|
||||
```
|
||||
--****************
|
||||
```sql
|
||||
set @count = @count + 1
|
||||
set @dt = DATEADD(ss,15,@dt) --每次递增30秒
|
||||
```
|
||||
end
|
||||
Reference in New Issue
Block a user