Tag:sqlserver cursor
declare temp_cursor cursor scroll for select cityname from corelinklinshi -- must have an SQL statement here, not empty open TEMP_CURSOR DECLARE @CityName varchar () FETCH NEXT FROM TEMP_CURSOR INTO @CityName while @ @FETCH_STATUS =0 begin declare @VALIDTIME varchar, @ENDTIME varchar (+) SET @VALIDTIME =convert (CHAR), GETDATE (), (+) + ' 00:00:00 ' SET @ENDTIME =convert (CHAR), DATEADD (Day,1,getdate ()), (+) + ' 00:00:00 ' while (CONVERT (datetime, @VALIDTIME) < convert (datetime, @ENDTIME)) &Nbsp; 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), DATEADD (Mi,15,convert (DATETIME, @VALIDTIME)), END FETCH NEXT FROM temp_cursor into @CityName END close temp_cursor deallocate temp_cursor
This article is from the "Silent" blog, please be sure to keep this source http://ruiwen.blog.51cto.com/8852761/1564195
Usage of SQL Server cursors