declare @basisname varchar ( 10 ) set @basisname = ' 底片格式 ' declare @basissortid int DECLARE mycursor CURSOR local FOR -- 定义游标 select sortid from tsort where sortid between 87 and 97 OPEN mycursor FETCH NEXT FROM mycursor INTO @basissortid WHILE @@FETCH_STATUS = 0 -- 循环游标,即循环当前类的弟一级子类 BEGIN insert into tbasis (basisname,basistypeid,basissortid,basistopid,basisparentid,basiscontent,int1,varchar1) values ( @basisname , 0 , @basissortid , 3 , 0 , null , 1 , null ) FETCH NEXT FROM mycursor INTO @basissortid End CLOSE mycursor DEALLOCATE mycursor