IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID('[dbo].[mps_delete_prd]') AND type = 'P')
DROP PROCEDURE [dbo].[mps_delete_prd]
GO
create procedure [dbo].[mps_delete_prd](
@cmpid int,
@pctag int,
@prdid bigint
)
as
begin
set nocount on
declare @tbname varchar(50)
declare @dbname varchar(50)
declare @fkey   varchar(50) 
exec sys_sql_getTableNamePk @cmpid,'prd',@pctag,0,@tbname output,@fkey output ,@dbname output 
declare @sql nvarchar(4000) 
set @sql = 'delete '+@dbname+@tbname+' where prd_id='+LTRIM(rtrim(str(@prdid)))  
execute(@sql) 
set nocount off
end