IF NOT EXISTS (SELECT * FROM SYS.OBJECTS WHERE OBJECT_ID = OBJECT_ID(N'DBO.PDV_VD_VINC_SAT_ENVIADA') AND TYPE IN (N'U'))
BEGIN

CREATE TABLE dbo.PDV_VD_VINC_SAT_ENVIADA (
    CD_EMP int NULL,
    CD_FILIAL int NULL,
    CD_VD int NULL,
    CD_CX int NULL,
    TIPO int NULL,
    CHAVE varchar(50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
    DT_CAD datetime NULL,
    DT_VD datetime NULL,
    NR_ECF int NULL,
    VLR_LIQ_VD money NULL,
    STS_VD int NULL
);

END

IF NOT EXISTS (SELECT 1 FROM SYS.INDEXES WHERE NAME = 'IDX_PDV_VD_VINC_SAT_ENVIADA_CD_EMP_CD_FILIAL_CUPOM')
BEGIN
	CREATE NONCLUSTERED INDEX IDX_PDV_VD_VINC_SAT_ENVIADA_CD_EMP_CD_FILIAL_CUPOM ON dbo.PDV_VD_VINC_SAT_ENVIADA (  CD_EMP ASC  , CD_FILIAL ASC  , NR_ECF ASC  )  
     WITH (  PAD_INDEX = OFF ,FILLFACTOR = 100  ,SORT_IN_TEMPDB = OFF , IGNORE_DUP_KEY = OFF , STATISTICS_NORECOMPUTE = OFF , ONLINE = OFF , ALLOW_ROW_LOCKS = ON , ALLOW_PAGE_LOCKS = ON  )
     ON [PRIMARY ] ;
END