IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID('[dbo].[mps_g_crmflows]') AND type = 'P')
DROP PROCEDURE [dbo].[mps_g_crmflows]
GO
CREATE procedure [dbo].[mps_g_crmflows] 
@mycrmid int ,
@flwtitle nvarchar(100) 
as
begin
   set nocount on
   if (@flwtitle<>'_none_' and @flwtitle<>'')
   begin
   declare @crmid int 
   select top 1 @crmid=flw_id from mps_bizflow where flw_bizid=@mycrmid and flw_title=@flwtitle 
   set @crmid = isnull(@crmid,0) 
   if (@crmid=0)
   begin
   insert into mps_bizflow(flw_bizid , flw_title,flw_scope,flw_xml) 
values(@mycrmid,@flwtitle,'','') 
   end 
end
select * from mps_bizflow where flw_bizid=@mycrmid  order by flw_id 
set nocount off 
end