IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID('[dbo].[mps_g_biztype_crmnames]') AND type = 'P')
DROP PROCEDURE [dbo].[mps_g_biztype_crmnames]
GO
CREATE procedure [dbo].[mps_g_biztype_crmnames](
@cmpid int,
@bizid int)
as
begin


select a.biz_id , a.biz_title , a.biz_database 
from mps_biztype a , mps_biztype b 
where a.biz_table=0 and a.biz_cmpid=@cmpid and a.biz_id=@bizid   and a.biz_id<>b.biz_id and 
a.biz_category=b.biz_category and a.biz_subcategory=b.biz_subcategory 
and b.biz_id=@bizid 

    select * from mps_biztype where biz_cmpid=@cmpid and biz_id=@bizid 
end