IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID('[dbo].[mps_g_bizsources]') AND type = 'P')
DROP PROCEDURE [dbo].[mps_g_bizsources]
GO
CREATE procedure [dbo].[mps_g_bizsources] 
@bizid int as
begin
set nocount on
declare @s nvarchar(4000) 
select top 1 @s=biz_sourcebizids from mps_biztype where biz_id=@bizid 
set @s = isnull(@s,'') 
declare @s1 varchar(200) 
declare @s2 varchar(200) 
declare @s3 varchar(200) 
declare @i int
declare @t table(bizid int , biztype varchar(10),biztitle nvarchar(100)) 
while (@s>'') 
begin
set @i = charindex(',',@s) 
if (@i>0) 
begin
set @s1 = substring(@s,1,@i-1) 
set @s = substring(@s,@i+1,len(@s)-@i) 
end else 
begin
set @s1 = @s 
set @s=''
end 
if (@s1>' ') 
begin
set @i = charindex('.',@s1) 
set @s2='' 
set @s3='' 
if (@i>0) 
begin
set @s2=substring(@s1,1,@i-1) 
set @s1=substring(@s1,@i+1,len(@s1)-@i) 
set @i = charindex('=',@s1) 
if (@i>0)
begin
set @s3=substring(@s1,1,@i-1) 
set @s1=substring(@s1,@i+1,len(@s1)-@i) 
end
end 
if (@s1>'' and @s2>'' and @s3>'') 
insert into @t(bizid,biztype,biztitle) values(convert(int,@s3),@s2,@s1) 
end 
end 
select * from @t 
set nocount off  
end