DECLARE ckxh CURSOR GLOBAL SCROLL FOR select * from #T_inventory /*创建游标*/ Open ckxh /*打开游标*/ FETCH FIRST from ckxh INTO @wlbm,@jwlbm,@wmtm,@wmmc,@ckmc,@wlfz,@kc /*取第一行*/ insert into #T_inventoryNew values(@wlbm,@jwlbm,@wmtm,@wmmc,@kc,@kc,@kc,@kc,@kc,@kc) WHILE @@fetch_status=0 BEGIN FETCH NEXT from ckxh INTO @wlbm,@jwlbm,@wmtm,@wmmc,@ckmc,@wlfz,@kc /*取下一行*/ insert into #T_inventoryNew values(@wlbm,@jwlbm,@wmtm,@wmmc,@kc,@kc,@kc,@kc,@kc,@kc) END Close ckxh --关闭游标 Deallocate ckxh --删除游标 select * from #T_inventoryNew
我用游标查询了一个表 然后在插入一个新表。但是最后一行出现了重复