ALTER TABLE INFCOM ADD COM_TCN VARCHAR(3),COM_NCN INT DEFAULT(0),COM_TCF VARCHAR(3),COM_NCF INT DEFAULT(0)
GO
CREATE TABLE NIIFCOMPROBANTE ( 
COM_TIP VARCHAR(3) NOT NULL,
COM_NUM INT DEFAULT ((0)) NOT NULL,
COM_CIA CHAR(2) DEFAULT ('01') NOT NULL,
COM_FEC SMALLDATETIME NOT NULL,
COM_TRN VARCHAR(10) DEFAULT ('NIIF') NOT NULL,
COM_NIT VARCHAR(11),
COM_TCG VARCHAR(3),
COM_NCG INT DEFAULT ((0)) NOT NULL,
COM_TCN VARCHAR(3),
COM_NCN INT DEFAULT ((0)) NOT NULL,
COM_DEV BIT DEFAULT ((0)) NOT NULL,
COM_OBS VARCHAR(250),
COM_USU VARCHAR(10)
 CONSTRAINT PK_NIIFCOMPROBANTE PRIMARY KEY CLUSTERED (COM_TIP,COM_NUM,COM_CIA),
 CONSTRAINT CK_NIIFCOMPROBANTECOM_CIA CHECK ((len([COM_CIA])>(0))),
 CONSTRAINT CK_NIIFCOMPROBANTECOM_TIP CHECK ((len([COM_TIP])>(0))),
 CONSTRAINT CK_NIIFCOMPROBANTECOM_TRN CHECK ((len([COM_TRN])>(0))))
CREATE TABLE NIIFDETALLE ( 
MOV_TIP VARCHAR(3) NOT NULL,
MOV_NUM INT DEFAULT ((0)) NOT NULL,
MOV_CIA CHAR(2) DEFAULT ('01') NOT NULL,
MOV_ITM INT DEFAULT ((0)) NOT NULL,
MOV_FEC SMALLDATETIME NOT NULL,
MOV_CUE VARCHAR(16) NOT NULL,
MOV_DET VARCHAR(250) NOT NULL,
MOV_DEB MONEY DEFAULT ((0)),
MOV_CRE MONEY DEFAULT ((0)),
MOV_CON VARCHAR(3),
MOV_NIT VARCHAR(11),
MOV_BAS MONEY DEFAULT ((0)),
MOV_TDC VARCHAR(3),
MOV_DOC INT DEFAULT ((0)),
MOV_CDC CHAR(2) DEFAULT ('01'),
MOV_TFA VARCHAR(3),
MOV_FAC VARCHAR(10),
MOV_NV DECIMAL(14,4) DEFAULT ((0)),
MOV_CFA CHAR(2) DEFAULT ('01'),
MOV_FVC SMALLDATETIME,
MOV_CTA VARCHAR(3),
MOV_CHE VARCHAR(20),
MOV_INT BIT DEFAULT ((0)) NOT NULL,
MOV_VEN CHAR(1) DEFAULT ('N'),
MOV_CC VARCHAR(3),
MOV_AGE VARCHAR(9) DEFAULT ('N'),
MOV_USU VARCHAR(10),
MOV_CCG VARCHAR(16)
 CONSTRAINT PK_NIIFDETALLE PRIMARY KEY CLUSTERED (MOV_TIP,MOV_NUM,MOV_CIA,MOV_ITM),
 CONSTRAINT CK_NIIFDETALLEMOV_CIA CHECK ((len([MOV_CIA])>(0))),
 CONSTRAINT CK_NIIFDETALLEMOV_CUE CHECK ((len([MOV_CUE])>(0))),
 CONSTRAINT CK_NIIFDETALLEMOV_DET CHECK ((len([MOV_DET])>(0))),
 CONSTRAINT CK_NIIFDETALLEMOV_TIP CHECK ((len([MOV_TIP])>(0))))
GO
CREATE NONCLUSTERED INDEX IX_NIIFCOMPROBANTECOM_FEC ON NIIFCOMPROBANTE(COM_FEC)
CREATE NONCLUSTERED INDEX IX_NIIFDETALLEMOV_FEC ON NIIFDETALLE(MOV_FEC)
CREATE NONCLUSTERED INDEX IX_NIIFDETALLEMOV_CUE ON NIIFDETALLE(MOV_CUE)