IF EXISTS ( SELECT * 
            FROM   sysobjects 
            WHERE  id = object_id(N'dbo.CP_Productos_xCampos_Copiar') 
                   and OBJECTPROPERTY(id, N'IsProcedure') = 1 )
BEGIN
    DROP PROCEDURE dbo.CP_Productos_xCampos_Copiar 
END
GO

CREATE PROCEDURE [dbo].[CP_Productos_xCampos_Copiar] (@pId_Producto_Origen VARCHAR(14), @pId_Producto_Destino VARCHAR(14))
AS
DECLARE @Mensaje VARCHAR(100)

BEGIN TRY
	BEGIN TRAN


	INSERT INTO Productos_xCampos
	SELECT @pId_Producto_Destino, Id_Campo, Valor_String, Valor_Integer, Valor_DT, Valor_Decimal, Valor_Memo FROM Productos_xCampos WHERE Id_Producto = @pId_Producto_Origen

	COMMIT
	SELECT	 0					AS ErrorNumber 
			,0					AS ErrorSeverity  
			,0					AS ErrorState 
			,0					AS ErrorProcedure  
			,0					AS ErrorLine		
			,@Mensaje			AS ErrorMessage
			,@pId_Producto_Destino	AS Id_Producto_Destino

	END TRY  


BEGIN CATCH  
    EXECUTE usp_GetErrorInfo;  
	ROLLBACK
END CATCH;