当前位置: 代码迷 >> Sql Server >> 多线程同时执行一个存储过程,如何才能取到不同的数据
  详细解决方案

多线程同时执行一个存储过程,如何才能取到不同的数据

热度:92   发布时间:2016-04-27 21:26:30.0
多线程同时执行一个存储过程,怎么才能取到不同的数据。
ALTER   PROCEDURE   [dbo].[sp_tmp_ad_GetIDS]  
(
@TaskID   int,
@sid   int,
@n   int
)
AS
BEGIN        
        declare   @table   table(id   int,keyword   nvarchar(200))
declare   @keywordid   int
declare   @gettime   datetime
select   @gettime=getdate()
update   dbo.map_job_task   set   [email protected]   where     [email protected]   and   [email protected]  
select   @keywordid=keywordid   from   dbo.map_job_task   where   [email protected]   and   [email protected]   and   [email protected]
update   dbo.map_job_task   set   [email protected]   where     [email protected]   and   [email protected]   and   [email protected]
if(@@rowcount> 0)
begin
insert   into   @table  
select   top(@n)   id,keyword   from   dt_keyword   where   id> @keywordid   and   tag   is   null   order   by   id
select   *   from   @table
end
else
exec   sp_tmp_ad_GetIDS   @TaskID,@sid,@n
--sp_tmp_ad_GetIDS
END

------解决方案--------------------
传的参数不同 数据就不同
------解决方案--------------------
对啊,传参变一下就好了
  相关解决方案