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

CREATE VIEW [dbo].[V_PRC_FILIAL_TENTACLE] 
AS
SELECT
	ALIQ_ICMS,
	BAIRRO,
	BLQ_DESC_PGTO_PRAZO,
	CD_CID,
	CD_EMP,
	CD_FILIAL,
	CD_MOD_CF_SPED_FISCAL,
	CEP,
	CGC,
	COMPLEMENTO,
	END_FILILAL AS END_FILIAL,
	FILIAL_MTZ,
	FLAG_DESC_VLR,
	INSC_EST,
	INSC_MUNI,
	ISNULL(PERC_ICMS_SIMPLES_NACIONAL, 0) AS PERC_ICMS_SIMPLES_NACIONAL,
	NM_FANT,
	PERC_DESC_TELE_ENT,
	PERC_DESC_VENDA,
	REGIME_TRIBUTARIO AS FLAG_MICRO_EMPRESA,
	RZ_FILIAL,
	SENHA_USU_PHARMALINK,
	TEL,
	FLAG_CARGA as st_carga,
	TP_PRECO_PROD,
	VLR_VENDA_DESC,
	VLR_VENDA_TELE_ENT_DESC,
	0 as flag_desc_vlr_a_vista,
	0 as reg_alterado,
	0 as registro_anvisa,
	0 as cd_regime_trib_sn
FROM PRC_FILIAL
WHERE PRC_FILIAL.CD_EMP = 1
GO