DECLARE @ProName NVARCHAR(50)
DECLARE @CityName NVARCHAR(50)DECLARE @ProId INT DECLARE @CityId INT DECLARE Test_Cursor CURSOR LOCAL READ_ONLY STATIC FORWARD_ONLY FORSELECT a.AreaId,a.AreaName,b.AreaName FROM AreaFull AS a RIGHT JOIN AreaFull AS b ON a.AreaPid=b.AreaId WHERE a.AreaPid>34OPEN Test_CursorFETCH NEXT FROM Test_Cursor INTO @CityId,@CityName,@ProNameWHILE @@FETCH_STATUS = 0BEGINSET @ProId=(SELECT ID FROM dbo.Web_Area WHERE Name=@ProName AND OrderId=27 )INSERT INTO Web_Area(Name,HeadID,LV,Family,OrderId) VALUES(@CityName,@ProId,4,4,28)FETCH NEXT FROM Test_Cursor INTO @CityId,@CityName,@ProNameENDCLOSE Test_cursorDEALLOCATE Test_cursorSELECT * FROM dbo.Web_Area