server sql 400W的表,批量更新
declare @SecCode varchar(12) declare @sql_cmd varchar(2000) declare sp cursor for select SecCode from #STK_MKT_tmp where SecCode=SecCode open sp fetch next from sp into @SecCode while(@@fetch_status=0) BEGIn set @sql_cmd= ‘update a set DEAL=b.DEAL,mtime=‘+‘‘‘2021-03-11 10:56:46.987‘‘‘+ ‘ from cgenius..STK_MKT a left join s7.ginagao.dbo.STK_MKT_DEAL b on a.tradedate=b.TRADEDATE and a.SecCode=b.STOCKCODE where a.DEAL is null and ISVALID=1 and a.SecCode=‘+@SecCode exec ( @sql_cmd) fetch next from sp into @SecCode END close sp deallocate sp
while
declare @a int,@b int set @a=1 while @a<22068549 begin set @b=@a+1000 insert into [tranconf_pp](S_TABNAME,PROCNAME,PARAM,UPDATEFIELD) select ‘INDX_CLOSE_WEIGHT‘,‘DP_INDX_CLOSE_WEIGHT_2_C_INDX_CLOSE_WEIGHT‘,SEQ,‘‘ FROM DATAPOOL..INDX_CLOSE_WEIGHT with (nolock) where seq between @a and @b set @a=@b+1 --- waitfor delay ‘00:03:00‘ truncate table tranconf_pp end
原文:https://www.cnblogs.com/gina11/p/14517006.html