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

CREATE VIEW [dbo].[V_PRC_FILIAL_IPDV] 
 	AS
	SELECT   CD_EMP, CD_FILIAL, RZ_FILIAL, END_FILILAL AS END_FILIAL, BAIRRO, CD_CID, CEP, TEL, FAX, CGC, INSC_MUNI
		    ,INSC_EST, NM_FANT, RESP, PERC_RED, RED_BASE_ICMS, ESP_NF, SR_NF, EMAIL, ALIQ_ICMS, TP_EMI_NF, MORA_BOL
			,REC_ATR, PROTS, DD_PROTS, INF_RED, CD_USU, DT_CAD, DT_ULT_ALT, CD_BC, TP_FILIAL, PROD_DIARIA, ROT_IMP_NF
			,REF_PESQ_PROD_MOV, PERC_ISS, PERC_IR, TP_PRECO_PROD, REF_PRECO, VD_EST_ZERADO, CONV_PROD_ENT, BX_EST_NF_DEV_AVULSA
			,NUM_ARQ_REM, ROT_IMP_BOL, END_ARQ_ORC_LINUX, END_ARQ_ORC, IP_SERV_FILIAL, IP_SERV_BD, END_ARQ_CARGA, FLAG_CARGA
			,FLAG_CONS_TELEVENDAS, FILIAL_MTZ, NV_PDV, QT_IT_NF, FLAG_TP_IMP, PREV_ENTG, POLO_DISTR, GERENTES, FLAGVINTEQUATROHORAS
			,HORAFECHAMENTO, HORAABERTURA, FLAGTIRALOJAAR, HORAABERTURA_SABADO, HORAFECHAMENTO_SABADO, HORAABERTURA_DOMINGO, HORAFECHAMENTO_DOMINGO
			,COMPLEMENTO, DT_INI_SISTEMA, TP_LANCTO_CHQ, FLAG_CONS, END_IMP_ORC_LINUX, FILIAL_MTZ_GRP_ECON, CTR_LOTE, QT_IT_OS, QT_SERV_NF
			,GERA_ARQ_PED, CTR_META, FLAG_TP_ORC, NM_ODBC_POSTGRES, NM_ODBC_POSTGRES_USUARIO, NM_USU_FARMACIA_POPULAR, SENHA_USU_FARMACIA_POPULAR
			,STS_FILIAL, FLAG_TP_RESSUPRIMENTO, TP_ROTINA_EMIS_NF, FLAG_NAO_PARTIC_INDIC, FLAG_OPERADOR_LOG, NR_LICENCA, VLR_LIMIT_DIF_CX
			,CD_FILIAL_CONTAB, FLAG_DESC_VLR, VLR_VENDA_DESC, PERC_DESC_VENDA,CD_FILIAL_ANT,CTR_SELO_NOTA_SAIDA,CNPJ_FARMACIA_POPULAR
			,FLAG_TP_REQ_LOJA,BLQ_DESC_PGTO_PRAZO,LC_DANFE_NFE,LC_GERA_NFE,IGNORA_IMPOSTO_NF_ENT,DATA_SYNC_SERV,CTR_FORM_CONTINUO,DT_INV_INICIAL_SNGPC
			,TELE_NOVO,HOME_PAGE,SENHA_USU_PHARMALINK,FLAG_SOM_CHECK_OUT,ESPECIE_FILIAL,FLAG_IGNORAR_PONTUACAO,FLAG_IGNORAR_EXCESSO_SUPRIMENTO
			,VLR_VENDA_TELE_ENT_DESC,PERC_DESC_TELE_ENT,ORDEM_LST_FILIAL,MULTA_BOL,NM_FILIAL_LISTA,TEXTO_RODAPE_CARTA_COBRANCA,FILIAL_COPIA_MTZ
			,REGIME_TRIBUTARIO,ENVIAR_XML_NFE,DS_SIGLA_FILIAL_CP,FLAG_CONSOLIDADOR_ATIVO,PERC_CUSTO_FIXO,CD_IMS_ENVIO,IMG_LOGO_FILIAL,FLAG_NOTA_FISCAL_ENTRADA_AUTOMATICA
			,AREA,FLAG_VALIDAR_NOTA_ENTRADA_FORN,FLAG_NFE_HABILITADA,FLAG_SNGPC_HABILITADO,CD_EMPRESA_CONTABIL,CD_CENTRO_CUSTO_CONTABIL,FLAG_TIPO_GERACAO_CUSTO_ICMS_CREDITO
			,PERFIL_SPED_FISCAL,FLAG_FILIAL_FRANQUIA, CD_MOD_CF_SPED_FISCAL,ISNULL(PERC_ICMS_SIMPLES_NACIONAL,0) AS PERC_ICMS_SIMPLES_NACIONAL,REGIME_TRIBUTARIO AS FLAG_MICRO_EMPRESA
	FROM PRC_FILIAL