DECLARE TEMP_CURSOR CURSOR SCROLL FOR SELECT CityName FROM CoreLinkLinShi -- 此处必须有Sql语句,不能空着 OPEN TEMP_CURSOR DECLARE @CityName varchar(50) FETCH NEXT FROM TEMP_CURSOR INTO @CityName WHILE @@FETCH_STATUS=0 BEGIN DECLARE @VALIDTIME VARCHAR(19),@ENDTIME VARCHAR(19) SET @VALIDTIME=CONVERT(CHAR(10),GETDATE(),23)+‘ 00:00:00‘ SET @ENDTIME=CONVERT(CHAR(10),DATEADD(DAY,1,GETDATE()),23)+‘ 00:00:00‘ WHILE(CONVERT(DATETIME,@VALIDTIME) < CONVERT(DATETIME,@ENDTIME)) BEGIN INSERT INTO dbo.CoreLink_temp(CityName,CompanyNo,SvrID,NeID,NeName,Slot,BoardName,Port,ValidTime) VALUES(@CityName,@CompanyNo,@SvrID,@NeID,@NeName,@Slot,@BoardName,@Port,@VALIDTIME) SET @VALIDTIME= CONVERT(CHAR(19),DATEADD(MI,15,CONVERT(DATETIME,@VALIDTIME)),120) END FETCH NEXT FROM TEMP_CURSOR INTO @CityName END CLOSE TEMP_CURSOR DEALLOCATE TEMP_CURSOR
时间: 2024-10-09 10:13:59