IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID('[dbo].[mps_save_program_ip]') AND type = 'P')
DROP PROCEDURE [dbo].[mps_save_program_ip]
GO
CREATE procedure [dbo].[mps_save_program_ip] 
@cmpid int,
@pageid int ,
@allows varchar(4000),
@forbids varchar(4000) 
as
begin
if (not exists (select pd_cmpid from mps_page_domain where pd_cmpid=@cmpid and pd_prid=@pageid )) 
begin
insert into mps_page_domain(pd_cmpid,pd_prid,pd_allow,pd_forbid)
values(@cmpid,@pageid,@allows,@forbids) 
end else 
begin
update mps_page_domain set pd_allow=@allows,pd_forbid=@forbids 
where pd_cmpid=@cmpid and pd_prid=@pageid 
end 
end