declare @depotid char(50),@s_name char(50) ,@code char(50),@name char(50),@st_phone char(50) ,@icount int = 0 declare hysl_cursor cursor for ( select b.st_phone, a.depotid,a.s_name,b.code,b.name from b_depot a left join b_employe b on a.id = b.depot_id where a.states = '1' and b.states = '1' and a.depotid not in (select 店铺编号 from #hysl where 店铺编号 is not null) --order by a.depotid ) open hysl_cursor; fetch next from hysl_cursor into @st_phone, @depotid,@s_name,@code,@name; while @@FETCH_STATUS = 0 begin print @icount --print @depotid insert into #hysl(orderby,xuhao,st_phone,店铺编号,店铺名称,导购编号,导购姓名,线下会员数量) values(0,0,@st_phone,@depotid,@s_name,@code,@name,0); fetch next from hysl_cursor into @st_phone, @depotid,@s_name,@code,@name; set @icount = @icount + 1 end close hysl_cursor; DEALLOCATE hysl_cursor; go 我用游标取出数据,有800多行,但是插入到表中就只插入200多行就停止插入了 |
最佳回答 |
||||
1
|
|