IF EXISTS(SELECT * FROM sys.views WHERE  object_id = OBJECT_ID(N'[dbo].[V_EST_PED_ELTR_FORN_EST_PED_CP]'))
	BEGIN
		DROP VIEW
			 [dbo].[V_EST_PED_ELTR_FORN_EST_PED_CP];
	END;
GO

CREATE VIEW [dbo].[V_EST_PED_ELTR_FORN_EST_PED_CP]
AS
	 SELECT DISTINCT
			dbo.EST_PED_ELTR_FORN_PED_CP.CD_EMP
		  , dbo.EST_PED_ELTR_FORN_PED_CP.CD_PED_SOL
		  , dbo.EST_PED_ELTR_FORN_PED_CP.CD_FIL_ENTR
		  , dbo.EST_PED_CP_IT.CD_PROD
		  , dbo.EST_PED_CP_IT.CD_PED AS CD_PED_CP
		  , dbo.EST_PED_CP_IT.QT_IT AS QT_IT_CP
		  , dbo.EST_PED_ELTR_FORN_PED_CP.CD_FORN
		  , EST_PED_ELTR_FORN_PED_CP.ORD_ENV
		  , dbo.EST_PED_CP_IT.QT_EMB
	 FROM
		 dbo.EST_PED_ELTR_FORN_PED_CP
		 INNER JOIN dbo.EST_PED_CP_IT ON dbo.EST_PED_ELTR_FORN_PED_CP.CD_EMP		  = dbo.EST_PED_CP_IT.CD_EMP
										 AND dbo.EST_PED_ELTR_FORN_PED_CP.CD_FIL_ENTR = dbo.EST_PED_CP_IT.CD_FILIAL
										 AND dbo.EST_PED_ELTR_FORN_PED_CP.CD_PED	  = dbo.EST_PED_CP_IT.CD_PED
		 --INNER JOIN EST_PED_CP_PENDENCIA ON dbo.EST_PED_CP_IT.CD_EMP = EST_PED_CP_PENDENCIA.CD_EMP
			--								AND dbo.EST_PED_CP_IT.CD_FILIAL = EST_PED_CP_PENDENCIA.CD_FILIAL
			--								AND dbo.EST_PED_CP_IT.CD_PED = EST_PED_CP_PENDENCIA.CD_PED;
GO


