Sqlserver游标的尝试
DECLARE @ProName NVARCHAR(50)
DECLARE @CityName NVARCHAR(50)
DECLARE @ProId INT
DECLARE @CityId INT
DECLARE Test_Cursor CURSOR FOR
SELECT a.AreaId,a.AreaName,b.AreaName FROM AreaFull AS a RIGHT JOIN AreaFull AS b ON a.AreaPid=b.AreaId WHERE a.AreaPid>34
OPEN Test_Cursor
FETCH NEXT FROM Test_Cursor INTO @CityId,@CityName,@ProName
WHILE @@FETCH_STATUS = 0
BEGIN
SET @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,@ProName
END
CLOSE Test_cursor
DEALLOCATE Test_cursor
SELECT * FROM dbo.Web_Area
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。