IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID('[dbo].[mps_g_adv_lists]') AND type = 'P')
DROP PROCEDURE [dbo].[mps_g_adv_lists]
GO
CREATE procedure [dbo].[mps_g_adv_lists](
@cmpid int,
@adnames varchar(1000) 
)
as
begin
set nocount on
SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED 
declare @s1 varchar(1000) 
declare @s varchar(100) 
declare @i int 
set @s1 = @adnames
declare @t table(name1 varchar(100)) 
while (@s1>'') 
begin
set @i = charindex(',',@s1) 
if (@i>0) 
begin
set @s = substring(@s1,1,@i-1) 
set @s1 = substring(@s1, @i + 1 , len(@s1)-@i) 
end else 
begin
set @s = @s1 
set @s1 = '' 
end 
if (@s>'') insert into @t(name1) values(@s) 
end 
select * from mps_advertisement with(nolock)  , @t where ad_cmpid=@cmpid and ad_name=name1 
set nocount off 
end