IF NOT EXISTS ( SELECT * FROM SYS.OBJECTS WHERE NAME = 'EST_NF_ENT_DANFE_CTE' )
BEGIN 

	CREATE TABLE [DBO].[EST_NF_ENT_DANFE_CTE] (
	  [CD_CTR]		INT IDENTITY(1, 1) NOT NULL,
	  [CD_EMP]		INT NOT NULL,
	  [CD_FILIAL]	INT NOT NULL,
	  [CD_FORN]		INT NOT NULL,
	  [CHCTE]		VARCHAR(50)  collate SQL_Latin1_General_CP1_CI_AS,
	  [CUF]			VARCHAR(50)  collate SQL_Latin1_General_CP1_CI_AS,
	  [CCT]			VARCHAR(50)  collate SQL_Latin1_General_CP1_CI_AS,
	  [CFOP]		VARCHAR(50)  collate SQL_Latin1_General_CP1_CI_AS,
	  [NATOP]		VARCHAR(250) collate SQL_Latin1_General_CP1_CI_AS,
	  [FORPAG]		INT NULL,
	  [MOD]		    INT NULL,
	  [SERIE]		INT NULL,
	  [NCT]			INT NULL,
	  [EMIT_CNPJ]	VARCHAR(30) collate SQL_Latin1_General_CP1_CI_AS,
	  [REMET_CNPJ]	VARCHAR(30) collate SQL_Latin1_General_CP1_CI_AS,
	  [EXPED_CNPJ]	VARCHAR(30) collate SQL_Latin1_General_CP1_CI_AS,
	  [DT_EMIS]		DATETIME NULL,
	  [TPCTE]		INT NULL,
	  [PROCEMI]		INT NULL,
	  [MODAL]		VARCHAR(30)  collate SQL_Latin1_General_CP1_CI_AS,
	  [TPSERV]		INT NULL,
	  [CMUNINI]		INT NULL,
	  [XMUNINI]		VARCHAR(150) collate SQL_Latin1_General_CP1_CI_AS ,
	  [UFINI]		VARCHAR(2) ,
	  [CMUNFIM]		INT NULL,
	  [XMUNFIM]		VARCHAR(250) collate SQL_Latin1_General_CP1_CI_AS,
	  [UFFIM]		VARCHAR(2)   collate SQL_Latin1_General_CP1_CI_AS,
	  [RETIRA]		VARCHAR(10)  collate SQL_Latin1_General_CP1_CI_AS,
	  [TOMA]		INT NULL,
	  [NR_AUTORIZADOR] VARCHAR(50) collate SQL_Latin1_General_CP1_CI_AS,
	  [VTPREST]		MONEY NULL,
	  [VREC]		MONEY NULL,
	  [ICMS_CST]	VARCHAR(3)	   collate SQL_Latin1_General_CP1_CI_AS,
	  [VLR_ICMS]	MONEY NULL,
	  [PERC_ICMS]	MONEY NULL,
	  [VLR_BASE_ICMS] MONEY NULL,
	  [CARGA]		VARCHAR(150) collate SQL_Latin1_General_CP1_CI_AS,
	  [PROPRED]		VARCHAR(150) collate SQL_Latin1_General_CP1_CI_AS,
	  [SEG_RESPSEG] VARCHAR(500) collate SQL_Latin1_General_CP1_CI_AS,
	  [SEG_XSEG]	VARCHAR(150) collate SQL_Latin1_General_CP1_CI_AS,
	  [SEG_NAPOL]	VARCHAR(150) collate SQL_Latin1_General_CP1_CI_AS,
	  [SEG_VCARGA]	VARCHAR(150) collate SQL_Latin1_General_CP1_CI_AS,
	  [TPMODAL]		VARCHAR(30)  collate SQL_Latin1_General_CP1_CI_AS,
	  [RNTRC]		VARCHAR(150) collate SQL_Latin1_General_CP1_CI_AS,
	  [DPREV]		DATETIME NULL,
	  [LOTA]		INT NULL,
	  [TP_AMB]		INT NULL,
	  [VER_APLIC]	VARCHAR(150) collate SQL_Latin1_General_CP1_CI_AS,
	  [DT_RECBTO]	DATETIME NULL,
	  [NPROT]		VARCHAR(150) collate SQL_Latin1_General_CP1_CI_AS,
	  [DIG_VAL]		VARCHAR(150) collate SQL_Latin1_General_CP1_CI_AS,
	  [CSTAT]		INT NULL,
	  [XMOTIVO]		VARCHAR(MAX) collate SQL_Latin1_General_CP1_CI_AS ,
	  [OBSERVACAO]	VARCHAR(MAX) collate SQL_Latin1_General_CP1_CI_AS ,
	  [VERSAO]		VARCHAR(30)  collate SQL_Latin1_General_CP1_CI_AS,
	  CONSTRAINT [PK_EST_NF_ENT_DANFE_CTE] PRIMARY KEY CLUSTERED ([CD_CTR])
	)
	ON [PRIMARY]

END 