IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID('[dbo].[checktask]') AND type = 'P')
DROP PROCEDURE [dbo].[checktask]
GO
create procedure [dbo].[checktask](
@tmid int , 
@res int output 
) as
begin
declare @re int = 0 
if (exists (select 1 from mps_timer_control with(nolock) where tm_name=@tmid and tm_status=0))  
begin
set @re = 1 
end else 
begin
set @re = 0 
update mps_timer_control with(rowlock) set tm_status=0  where tm_name=@tmid 
end 
set @res = @re 
end