/****** Object:  View [dbo].[V_PAINEL_NFE_EST_NF_SAI_TRANSFERENCIA_ERRO_ENTRADA_QTDE]    Script Date: 17/11/2018 11:00:00 ******/ 
IF EXISTS (SELECT * 
           FROM   SYS.VIEWS 
           WHERE  OBJECT_ID = 
      Object_id(N'[dbo].[V_PAINEL_NFE_EST_NF_SAI_TRANSFERENCIA_ERRO_ENTRADA_QTDE]')) 
  DROP VIEW [dbo].[V_PAINEL_NFE_EST_NF_SAI_TRANSFERENCIA_ERRO_ENTRADA_QTDE] 

GO

--SELECT * FROM V_PAINEL_NFE_EST_NF_SAI_TRANSFERENCIA_ERRO_ENTRADA_QTDE	WITH (NOLOCK)
CREATE VIEW [dbo].[V_PAINEL_NFE_EST_NF_SAI_TRANSFERENCIA_ERRO_ENTRADA_QTDE] AS
SELECT COUNT(1) QTDE_ERROS_ENTRADA_AUTO
FROM EST_NF_SAI_ERROS_VALIDACAO WITH (NOLOCK)
INNER JOIN EST_NF_SAI_PENDENCIA ON EST_NF_SAI_ERROS_VALIDACAO.CD_EMP = EST_NF_SAI_PENDENCIA.CD_EMP
AND EST_NF_SAI_ERROS_VALIDACAO.CD_FILIAL = EST_NF_SAI_PENDENCIA.CD_FILIAL
AND EST_NF_SAI_ERROS_VALIDACAO.CD_NF = EST_NF_SAI_PENDENCIA.CD_NF
WHERE EST_NF_SAI_ERROS_VALIDACAO.STS_ERRO=0