IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID('[dbo].[mps_gen_cstnewdetail_after_all]') AND type = 'P')
DROP PROCEDURE [dbo].[mps_gen_cstnewdetail_after_all]
GO
create procedure [dbo].[mps_gen_cstnewdetail_after_all](
@cmpid int,
@ctid int
)
as
begin
declare @cc2tag int 
declare c1 cursor LOCAL FORWARD_ONLY READ_ONLY for
select distinct  ct2_tag  from mps_csttype2  where   ct2_ctid=@ctid   
open c1
FETCH NEXT FROM c1 INTO @cc2tag 
WHILE (@@FETCH_STATUS = 0)
BEGIN
exec mps_gen_biznewdetail_after @cmpid ,@ctid ,@cc2tag 
 FETCH NEXT FROM c1 INTO @cc2tag 
END
CLOSE c1
DEALLOCATE c1
end