IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID('[dbo].[mps_new_privatesql]') AND type = 'P')
DROP PROCEDURE [dbo].[mps_new_privatesql]
GO
CREATE procedure [dbo].[mps_new_privatesql](
@cmpid int ,
@psname nvarchar(50)
)
as
begin
 set nocount on
 if (not exists (select * from mps_privatesql where ps_cmpid=@cmpid and ps_name=@psname)) 
 begin
 insert into mps_privatesql(ps_cmpid,ps_name) values(@cmpid,@psname) 
 declare @psid int 
 set @psid=@@Identity  
 select * from mps_privatesql where ps_id=@psid 
 end else 
 begin
 select 1 where 1=0
 end 
set nocount off
end