CREATE TABLE APROPED ( 
APR_TIP VARCHAR(3) DEFAULT ('APR') NOT NULL,
APR_NUM INT DEFAULT (0) NOT NULL,
APR_CIA CHAR(2) DEFAULT ('01') NOT NULL,
APR_FEC SMALLDATETIME NOT NULL,
APR_TPE VARCHAR(3) DEFAULT ('PED') NOT NULL,
APR_PED INT DEFAULT (0) NOT NULL,
APR_CPE CHAR(2) DEFAULT ('01') NOT NULL,
APR_FPE SMALLDATETIME
 CONSTRAINT PK_APROPED PRIMARY KEY CLUSTERED (APR_TIP,APR_NUM,APR_CIA),
 CONSTRAINT CK__APROPED__APR_CIA__6A50C1DA CHECK ((len([APR_CIA]) > 0)),
 CONSTRAINT CK__APROPED__APR_CPE__6F1576F7 CHECK ((len([APR_CPE]) > 0)),
 CONSTRAINT CK__APROPED__APR_TIP__6774552F CHECK ((len([APR_TIP]) > 0)),
 CONSTRAINT CK__APROPED__APR_TPE__6C390A4C CHECK ((len([APR_TPE]) > 0)))
CREATE TABLE AUTORIZA ( 
AUT_TIP VARCHAR(3) DEFAULT ('AUT') NOT NULL,
AUT_NUM INT DEFAULT (0) NOT NULL,
AUT_CIA CHAR(2) DEFAULT ('01') NOT NULL,
AUT_FEC SMALLDATETIME NOT NULL,
AUT_NOM VARCHAR(8) NOT NULL,
AUT_NIT VARCHAR(11),
AUT_CON VARCHAR(3) NOT NULL,
AUT_EST BIT DEFAULT (0) NOT NULL,
AUT_USU VARCHAR(10)
 CONSTRAINT PK_AUTORIZA PRIMARY KEY CLUSTERED (AUT_TIP,AUT_NUM,AUT_CIA),
 CONSTRAINT CK__AUTORIZA__AUT_CI__75C27486 CHECK ((len([AUT_CIA]) > 0)),
 CONSTRAINT CK__AUTORIZA__AUT_CO__77AABCF8 CHECK ((len([AUT_CON]) > 0)),
 CONSTRAINT CK__AUTORIZA__AUT_NO__76B698BF CHECK ((len([AUT_NOM]) > 0)),
 CONSTRAINT CK__AUTORIZA__AUT_TI__72E607DB CHECK ((len([AUT_TIP]) > 0)))
CREATE TABLE CONSIGNACIONES ( 
CON_NUM INT DEFAULT (0) NOT NULL,
CON_TIP VARCHAR(3) DEFAULT ('CNS') NOT NULL,
CON_CIA CHAR(2) DEFAULT ('01') NOT NULL,
CON_FEC SMALLDATETIME NOT NULL,
CON_CON VARCHAR(3) NOT NULL,
CON_CTA VARCHAR(3) NOT NULL,
CON_CUE VARCHAR(16),
CON_VAL MONEY DEFAULT (0),
CON_NIT VARCHAR(11)
 CONSTRAINT PK_CONSIGNACIONES PRIMARY KEY CLUSTERED (CON_NUM,CON_TIP,CON_CIA),
 CONSTRAINT CK__CONSIGNAC__CON_C__004002F9 CHECK ((len([CON_CON]) > 0)),
 CONSTRAINT CK__CONSIGNAC__CON_C__01342732 CHECK ((len([CON_CTA]) > 0)),
 CONSTRAINT CK__CONSIGNAC__CON_C__7F4BDEC0 CHECK ((len([CON_CIA]) > 0)),
 CONSTRAINT CK__CONSIGNAC__CON_T__7D63964E CHECK ((len([CON_TIP]) > 0)))
CREATE TABLE CUMPLIDOS ( 
CUM_TIP VARCHAR(3) NOT NULL,
CUM_NUM INT DEFAULT ((0)) NOT NULL,
CUM_CIA CHAR(2) DEFAULT ('01') NOT NULL,
CUM_FEC SMALLDATETIME NOT NULL,
CUM_TDC VARCHAR(3) DEFAULT ('PLT') NOT NULL,
CUM_NDC INT DEFAULT ((0)) NOT NULL,
CUM_CDC CHAR(2) NOT NULL,
CUM_RUT VARCHAR(3),
CUM_ORI VARCHAR(8),
CUM_DES VARCHAR(8),
CUM_NIT VARCHAR(11) NOT NULL,
CUM_VEH VARCHAR(10) NOT NULL,
CUM_CDT VARCHAR(11),
CUM_CON VARCHAR(3),
CUM_LPG VARCHAR(8),
CUM_DPG INT DEFAULT ((0)) NOT NULL,
CUM_FPG SMALLDATETIME,
CUM_POG DECIMAL(14,4) DEFAULT ((0)) NOT NULL,
CUM_PES DECIMAL(14,4) DEFAULT ((0)) NOT NULL,
CUM_VAL MONEY DEFAULT ((0)) NOT NULL,
CUM_COS MONEY DEFAULT ((0)) NOT NULL,
CUM_NET MONEY DEFAULT ((0)) NOT NULL,
CUM_VHC MONEY DEFAULT ((0)),
CUM_VHD MONEY DEFAULT ((0)),
CUM_VAD MONEY DEFAULT ((0)),
CUM_MVL VARCHAR(3),
CUM_VDC MONEY DEFAULT ((0)),
CUM_MVD VARCHAR(3),
CUM_FED SMALLDATETIME,
CUM_MTA VARCHAR(5),
CUM_OAC VARCHAR(250)
 CONSTRAINT PK_CUMPLIDOS PRIMARY KEY CLUSTERED (CUM_TIP,CUM_NUM,CUM_CIA),
 CONSTRAINT CK_CUMPLIDOSCUM_CDC CHECK ((len([CUM_CDC])>(0))),
 CONSTRAINT CK_CUMPLIDOSCUM_CIA CHECK ((len([CUM_CIA])>(0))),
 CONSTRAINT CK_CUMPLIDOSCUM_NIT CHECK ((len([CUM_NIT])>(0))),
 CONSTRAINT CK_CUMPLIDOSCUM_TDC CHECK ((len([CUM_TDC])>(0))),
 CONSTRAINT CK_CUMPLIDOSCUM_TIP CHECK ((len([CUM_TIP])>(0))),
 CONSTRAINT CK_CUMPLIDOSCUM_VEH CHECK ((len([CUM_VEH])>(0))))
CREATE TABLE DESPACHOS ( 
DES_TIP VARCHAR(3) DEFAULT ('PLT') NOT NULL,
DES_NUM INT DEFAULT (0) NOT NULL,
DES_CIA CHAR(2) DEFAULT ('01') NOT NULL,
DES_FEC SMALLDATETIME NOT NULL,
DES_HOR SMALLDATETIME,
DES_NIT VARCHAR(11) NOT NULL,
DES_VEH VARCHAR(10) NOT NULL,
DES_CON VARCHAR(11),
DES_RUT VARCHAR(3) NOT NULL,
DES_ORI VARCHAR(8) NOT NULL,
DES_DES VARCHAR(8) NOT NULL,
DES_REM VARCHAR(11),
DES_DTN VARCHAR(11),
DES_FIN BIT DEFAULT (0) NOT NULL,
DES_OBS VARCHAR(250),
DES_TOC VARCHAR(3) DEFAULT ('OCT'),
DES_OCT INT DEFAULT (0),
DES_COC CHAR(2) DEFAULT ('01'),
DES_FOC SMALLDATETIME,
DES_USU VARCHAR(10)
 CONSTRAINT PK_DESPACHOS PRIMARY KEY CLUSTERED (DES_TIP,DES_NUM,DES_CIA),
 CONSTRAINT CK__DESPACHOS__DES_C__08D548FA CHECK ((len([DES_CIA]) > 0)),
 CONSTRAINT CK__DESPACHOS__DES_D__0D99FE17 CHECK ((len([DES_DES]) > 0)),
 CONSTRAINT CK__DESPACHOS__DES_N__09C96D33 CHECK ((len([DES_NIT]) > 0)),
 CONSTRAINT CK__DESPACHOS__DES_O__0CA5D9DE CHECK ((len([DES_ORI]) > 0)),
 CONSTRAINT CK__DESPACHOS__DES_R__0BB1B5A5 CHECK ((len([DES_RUT]) > 0)),
 CONSTRAINT CK__DESPACHOS__DES_T__05F8DC4F CHECK ((len([DES_TIP]) > 0)),
 CONSTRAINT CK__DESPACHOS__DES_V__0ABD916C CHECK ((len([DES_VEH]) > 0)))
CREATE TABLE DETCUM ( 
DET_TIP VARCHAR(3) NOT NULL,
DET_NUM INT DEFAULT ((0)) NOT NULL,
DET_CIA CHAR(2) DEFAULT ('01') NOT NULL,
DET_ITM INT DEFAULT ((0)) NOT NULL,
DET_TDC VARCHAR(3) NOT NULL,
DET_NDC INT DEFAULT ((0)) NOT NULL,
DET_CDC CHAR(2) NOT NULL,
DET_IDC INT DEFAULT ((0)) NOT NULL,
DET_FDC SMALLDATETIME NOT NULL,
DET_PES DECIMAL(14,4) DEFAULT ((0)) NOT NULL,
DET_KGO DECIMAL(14,4) DEFAULT ((0)) NOT NULL,
DET_VAL MONEY DEFAULT ((0)) NOT NULL,
DET_COS MONEY DEFAULT ((0)) NOT NULL,
DET_NET MONEY DEFAULT ((0)) NOT NULL,
DET_ORI VARCHAR(8),
DET_CDE VARCHAR(8),
DET_UNI VARCHAR(3),
DET_NOV VARCHAR(3),
DET_RF1 VARCHAR(250),
DET_RF2 VARCHAR(250),
DET_RF3 VARCHAR(250),
DET_KRM DECIMAL(14,4) DEFAULT ((0)) NOT NULL,
DET_VRM MONEY DEFAULT ((0)) NOT NULL,
DET_CRM MONEY DEFAULT ((0)) NOT NULL,
DET_NRM MONEY DEFAULT ((0)) NOT NULL,
DET_COD VARCHAR(13),
DET_DES VARCHAR(250),
DET_CAN VARCHAR(10),
DET_CC VARCHAR(3),
DET_CLI VARCHAR(11),
DET_AGE VARCHAR(9)
 CONSTRAINT PK_DETCUM PRIMARY KEY CLUSTERED (DET_TIP,DET_NUM,DET_CIA,DET_ITM),
 CONSTRAINT CK_DETCUMDET_CDC CHECK ((len([DET_CDC])>(0))),
 CONSTRAINT CK_DETCUMDET_CIA CHECK ((len([DET_CIA])>(0))),
 CONSTRAINT CK_DETCUMDET_TDC CHECK ((len([DET_TDC])>(0))),
 CONSTRAINT CK_DETCUMDET_TIP CHECK ((len([DET_TIP])>(0))))
CREATE TABLE DETFIS ( 
DET_TIP VARCHAR(3) DEFAULT ('FIS') NOT NULL,
DET_NUM INT DEFAULT (0) NOT NULL,
DET_CIA CHAR(2) DEFAULT ('01') NOT NULL,
DET_ITM SMALLINT DEFAULT (0) NOT NULL,
DET_COD VARCHAR(16) NOT NULL,
DET_SEC VARCHAR(3) NOT NULL,
DET_TAN VARCHAR(3),
DET_CAN DECIMAL(14,4) DEFAULT (0) NOT NULL,
DET_SAL DECIMAL(14,4) DEFAULT (0),
DET_COS MONEY DEFAULT (0)
 CONSTRAINT PK_DETFIS PRIMARY KEY CLUSTERED (DET_TIP,DET_NUM,DET_CIA,DET_ITM),
 CONSTRAINT CK__DETFIS__DET_CIA__18178C8A CHECK ((len([DET_CIA]) > 0)),
 CONSTRAINT CK__DETFIS__DET_COD__19FFD4FC CHECK ((len([DET_COD]) > 0)),
 CONSTRAINT CK__DETFIS__DET_SEC__1AF3F935 CHECK ((len([DET_SEC]) > 0)),
 CONSTRAINT CK__DETFIS__DET_TIP__153B1FDF CHECK ((len([DET_TIP]) > 0)))
CREATE TABLE DETGUI ( 
DET_NUM INT DEFAULT (0) NOT NULL,
DET_TIP VARCHAR(3) DEFAULT ('GUI') NOT NULL,
DET_CIA CHAR(2) DEFAULT ('01') NOT NULL,
DET_ITM SMALLINT DEFAULT (0) NOT NULL,
DET_COD VARCHAR(16) NOT NULL,
DET_TAN VARCHAR(3) NOT NULL,
DET_COM VARCHAR(8),
DET_CAN DECIMAL(14,4) DEFAULT (0) NOT NULL,
DET_PCO BIT DEFAULT (0),
DET_SUR VARCHAR(3)
 CONSTRAINT PK_DETGUI PRIMARY KEY CLUSTERED (DET_NUM,DET_TIP,DET_CIA,DET_ITM),
 CONSTRAINT CK__DETGUI__DET_CIA__247D636F CHECK ((len([DET_CIA]) > 0)),
 CONSTRAINT CK__DETGUI__DET_COD__2665ABE1 CHECK ((len([DET_COD]) > 0)),
 CONSTRAINT CK__DETGUI__DET_TAN__2759D01A CHECK ((len([DET_TAN]) > 0)),
 CONSTRAINT CK__DETGUI__DET_TIP__22951AFD CHECK ((len([DET_TIP]) > 0)))
CREATE TABLE DETING ( 
DET_TIP VARCHAR(3) DEFAULT ('CIC') NOT NULL,
DET_NUM INT DEFAULT (0) NOT NULL,
DET_CIA CHAR(2) DEFAULT ('01') NOT NULL,
DET_ITM SMALLINT DEFAULT (0) NOT NULL,
DET_FEC SMALLDATETIME NOT NULL,
DET_CON VARCHAR(3) NOT NULL,
DET_DES VARCHAR(100),
DET_DEB MONEY DEFAULT (0) NOT NULL,
DET_CRE MONEY DEFAULT (0) NOT NULL,
DET_CUE VARCHAR(16),
DET_NIT VARCHAR(11),
DET_BAS MONEY DEFAULT (0),
DET_CC VARCHAR(3),
DET_CTA VARCHAR(3),
DET_TFA VARCHAR(3),
DET_FAC VARCHAR(10),
DET_CFA CHAR(2),
DET_NV SMALLINT DEFAULT (0),
DET_AGE VARCHAR(9),
DET_DSO BIT DEFAULT(0),
DET_TCN VARCHAR(20),
DET_IMP VARCHAR(10),
DET_CTI VARCHAR(3),
DET_TAR DECIMAL(14,4) DEFAULT(0),
DET_FVC SMALLDATETIME,
DET_ICO INT DEFAULT(0),
DET_TDS VARCHAR(3),
DET_NDS INT DEFAULT(0),
DET_CDS CHAR(2)
 CONSTRAINT PK_DETING PRIMARY KEY CLUSTERED (DET_TIP,DET_NUM,DET_CIA,DET_ITM),
 CONSTRAINT CK__DETING__DET_CIA__2EFAF1E2 CHECK ((len([DET_CIA]) > 0)),
 CONSTRAINT CK__DETING__DET_CON__30E33A54 CHECK ((len([DET_CON]) > 0)),
 CONSTRAINT CK__DETING__DET_TIP__2C1E8537 CHECK ((len([DET_TIP]) > 0)))
CREATE TABLE DETLEG ( 
DET_TIP VARCHAR(3) DEFAULT ('LEG') NOT NULL,
DET_NUM INT DEFAULT (0) NOT NULL,
DET_CIA CHAR(2) DEFAULT ('01') NOT NULL,
DET_ITM SMALLINT DEFAULT (0) NOT NULL,
DET_CON VARCHAR(3) NOT NULL,
DET_FEC SMALLDATETIME,
DET_DES VARCHAR(100),
DET_VAL MONEY DEFAULT (0),
DET_CUE VARCHAR(16),
DET_NIT VARCHAR(11),
DET_CC VARCHAR(3),
DET_CTA VARCHAR(3),
DET_BAS MONEY DEFAULT (0),
DET_CRE MONEY DEFAULT (0),
DET_CAN DECIMAL(16,4) DEFAULT ((0)),
DET_TAR DECIMAL(16,4) DEFAULT ((0)),
DET_TDS VARCHAR(3),
DET_NDS INT DEFAULT ((0)),
DET_CDS CHAR(2),
DET_DSO BIT DEFAULT(0),
DET_TCN VARCHAR(20),
DET_IMP VARCHAR(10),
DET_CTI VARCHAR(3),
DET_FVC SMALLDATETIME,
DET_ICO INT DEFAULT(0),
DET_TFA VARCHAR(3),
DET_FAC VARCHAR(10),
DET_CFA CHAR(2),
DET_NV INT DEFAULT(0)
 CONSTRAINT PK_DETLEG PRIMARY KEY CLUSTERED (DET_TIP,DET_NUM,DET_CIA,DET_ITM),
 CONSTRAINT CK__DETLEG__DET_CIA__3B60C8C7 CHECK ((len([DET_CIA]) > 0)),
 CONSTRAINT CK__DETLEG__DET_CON__3D491139 CHECK ((len([DET_CON]) > 0)),
 CONSTRAINT CK__DETLEG__DET_TIP__38845C1C CHECK ((len([DET_TIP]) > 0)))
CREATE TABLE DETMOR ( 
DET_TIP VARCHAR(3) DEFAULT ('MOR') NOT NULL,
DET_NUM INT DEFAULT (0) NOT NULL,
DET_CIA CHAR(2) DEFAULT ('01') NOT NULL,
DET_ITM SMALLINT DEFAULT (0) NOT NULL,
DET_FEC SMALLDATETIME NOT NULL,
DET_TFA VARCHAR(3) DEFAULT ('FCR') NOT NULL,
DET_NFA INT DEFAULT (0) NOT NULL,
DET_CFA CHAR(2) DEFAULT ('01') NOT NULL,
DET_NV SMALLINT DEFAULT (0) NOT NULL,
DET_FVC SMALLDATETIME NOT NULL,
DET_INI SMALLDATETIME,
DET_FIN SMALLDATETIME,
DET_DIA SMALLINT DEFAULT (0) NOT NULL,
DET_SAL MONEY DEFAULT (0) NOT NULL,
DET_VAL MONEY DEFAULT (0) NOT NULL,
DET_IVA MONEY DEFAULT (0),
DET_NIT VARCHAR(11) NOT NULL,
DET_AGE VARCHAR(9) DEFAULT ('N'),
DET_NOT INT DEFAULT (0)
 CONSTRAINT PK_DETMOR PRIMARY KEY CLUSTERED (DET_TIP,DET_NUM,DET_CIA,DET_ITM),
 CONSTRAINT CK__DETMOR__DET_CFA__4C8B54C9 CHECK ((len([DET_CFA]) > 0)),
 CONSTRAINT CK__DETMOR__DET_CIA__46D27B73 CHECK ((len([DET_CIA]) > 0)),
 CONSTRAINT CK__DETMOR__DET_NIT__52442E1F CHECK ((len([DET_NIT]) > 0)),
 CONSTRAINT CK__DETMOR__DET_TFA__49AEE81E CHECK ((len([DET_TFA]) > 0)),
 CONSTRAINT CK__DETMOR__DET_TIP__43F60EC8 CHECK ((len([DET_TIP]) > 0)))
CREATE TABLE DETMOV ( 
DET_TIP VARCHAR(3) NOT NULL,
DET_NUM INT DEFAULT ((0)) NOT NULL,
DET_CIA CHAR(2) DEFAULT ('01') NOT NULL,
DET_ITM SMALLINT DEFAULT ((0)) NOT NULL,
DET_FEC SMALLDATETIME NOT NULL,
DET_TDC VARCHAR(3) DEFAULT ('RMT') NOT NULL,
DET_ORD INT DEFAULT ((0)) NOT NULL,
DET_COD CHAR(2) NOT NULL,
DET_LIN SMALLINT DEFAULT ((0)),
DET_FDC SMALLDATETIME,
DET_CAR VARCHAR(13) NOT NULL,
DET_DES VARCHAR(80),
DET_CAN VARCHAR(10) DEFAULT ('0'),
DET_PES DECIMAL(14,4) DEFAULT ((0)),
DET_UNI VARCHAR(3),
DET_REF VARCHAR(250),
DET_EMP VARCHAR(3),
DET_NAT VARCHAR(3),
DET_REM VARCHAR(11),
DET_NRM VARCHAR(150),
DET_DTN VARCHAR(11),
DET_NDE VARCHAR(150),
DET_PAG VARCHAR(11),
DET_ORI VARCHAR(8),
DET_DOR VARCHAR(250),
DET_CDE VARCHAR(8),
DET_DDE VARCHAR(250),
DET_VAL MONEY DEFAULT ((0)),
DET_COS MONEY DEFAULT ((0)),
DET_NET MONEY DEFAULT ((0)),
DET_FAL MONEY DEFAULT ((0)),
DET_DCT MONEY DEFAULT ((0)),
DET_IVA MONEY DEFAULT ((0)),
DET_FAC INT DEFAULT ((-1)),
DET_CFA CHAR(2),
DET_PED INT DEFAULT ((-1)),
DET_CPE CHAR(2),
DET_VEH VARCHAR(10),
DET_TVH CHAR(1) DEFAULT ('A'),
DET_CON VARCHAR(3),
DET_DEV INT DEFAULT ((-1)),
DET_FDV SMALLDATETIME,
DET_RAN VARCHAR(3),
DET_KLR DECIMAL(14,4) DEFAULT ((0)),
DET_RF1 VARCHAR(250),
DET_RF3 VARCHAR(250),
DET_ICA MONEY DEFAULT ((0)),
DET_PIC DECIMAL(10,4) DEFAULT ((0)),
DET_CPI VARCHAR(3),
DET_VRF MONEY DEFAULT ((0)),
DET_PRF DECIMAL(10,4) DEFAULT ((0)),
DET_CPR VARCHAR(3),
DET_CC VARCHAR(3),
DET_NMT VARCHAR(20) DEFAULT ('0'),
DET_TIV VARCHAR(3),
DET_INV INT DEFAULT ((0)),
DET_CIV CHAR(2),
DET_BOD VARCHAR(3),
DET_SDR VARCHAR(4),
DET_SDD VARCHAR(4),
DET_ARI MONEY DEFAULT ((0)),
DET_PEC DECIMAL(14,4) DEFAULT ((0)),
DET_POF DECIMAL(14,4) DEFAULT ((0)),
DET_VCM MONEY DEFAULT ((0)),
DET_CCM MONEY DEFAULT ((0)),
DET_NCM MONEY DEFAULT ((0)),
DET_TBD INT DEFAULT ((0)),
DET_CMA MONEY DEFAULT ((0)),
DET_NMA VARCHAR(11),
DET_VMA VARCHAR(10),
DET_FTC MONEY DEFAULT ((0)) NOT NULL,
DET_FTP MONEY DEFAULT ((0)) NOT NULL,
DET_FTN MONEY DEFAULT ((0)) NOT NULL,
DET_IAT MONEY DEFAULT(0) NOT NULL,
DET_TAT DECIMAL(14,4) DEFAULT(0) NOT NULL,
DET_CAT VARCHAR(3),
DET_BOM MONEY DEFAULT(0) NOT NULL,
DET_TIB DECIMAL(14,4) DEFAULT(0) NOT NULL,
DET_CIB VARCHAR(3),
DET_ART MONEY DEFAULT(0) NOT NULL,
DET_ARB MONEY DEFAULT(0) NOT NULL
 CONSTRAINT PK_DETMOV PRIMARY KEY CLUSTERED (DET_TIP,DET_NUM,DET_CIA,DET_ITM),
 CONSTRAINT CK__DETMOV__DET_CAR__5EAA0504 CHECK ((len([DET_CAR])>(0))),
 CONSTRAINT CK__DETMOV__DET_CIA__59E54FE7 CHECK ((len([DET_CIA])>(0))),
 CONSTRAINT CK__DETMOV__DET_TIP__5708E33C CHECK ((len([DET_TIP])>(0))))
CREATE TABLE DETSER ( 
DET_TIP VARCHAR(3) DEFAULT ('PDT') NOT NULL,
DET_NUM INT DEFAULT (0) NOT NULL,
DET_CIA CHAR(2) DEFAULT ('01') NOT NULL,
DET_ITM INT DEFAULT (0) NOT NULL,
DET_FEC SMALLDATETIME NOT NULL,
DET_CLA VARCHAR(10) NOT NULL,
DET_CAR VARCHAR(13) NOT NULL,
DET_DES VARCHAR(150),
DET_CAN DECIMAL(10,4) DEFAULT (0) NOT NULL,
DET_PES DECIMAL(10,4) DEFAULT (0) NOT NULL,
DET_UNI VARCHAR(3) NOT NULL,
DET_VOL DECIMAL(10,4) DEFAULT (0) NOT NULL,
DET_EMP VARCHAR(3) NOT NULL,
DET_NAT VARCHAR(3),
DET_TVH VARCHAR(3),
DET_TCO VARCHAR(3),
DET_NCO VARCHAR(50),
DET_NAV VARCHAR(3),
DET_CRC VARCHAR(8),
DET_PRC VARCHAR(50),
DET_COS MONEY DEFAULT (0) NOT NULL,
DET_VAL MONEY DEFAULT (0) NOT NULL,
DET_REF VARCHAR(50)
 CONSTRAINT PK_DETSER PRIMARY KEY CLUSTERED (DET_TIP,DET_NUM,DET_CIA,DET_ITM),
 CONSTRAINT CK_DETSERDET_CAR CHECK ((len([DET_CAR]) > 0)),
 CONSTRAINT CK_DETSERDET_CIA CHECK ((len([DET_CIA]) > 0)),
 CONSTRAINT CK_DETSERDET_CLA CHECK (([DET_CLA] = 'OTRO' or ([DET_CLA] = 'CUPO' or ([DET_CLA] = 'CONTENEDOR' or [DET_CLA] = 'SUELTA')))),
 CONSTRAINT CK_DETSERDET_EMP CHECK ((len([DET_EMP]) > 0)),
 CONSTRAINT CK_DETSERDET_TIP CHECK ((len([DET_TIP]) > 0)),
 CONSTRAINT CK_DETSERDET_UNI CHECK ((len([DET_UNI]) > 0)))
CREATE TABLE DEVOLUCIONES ( 
DEV_NUM INT DEFAULT (0) NOT NULL,
DEV_TIP VARCHAR(3) NOT NULL,
DEV_CIA CHAR(2) DEFAULT ('01') NOT NULL,
DEV_FEC SMALLDATETIME NOT NULL,
DEV_CON VARCHAR(3) NOT NULL,
DEV_CLI VARCHAR(11),
DEV_AGE VARCHAR(9) DEFAULT ('N'),
DEV_TDC VARCHAR(3) NOT NULL,
DEV_DOC INT DEFAULT (0) NOT NULL,
DEV_CDC CHAR(2) DEFAULT ('01'),
DEV_VAL MONEY DEFAULT (0),
DEV_IVA MONEY DEFAULT (0),
DEV_DCT MONEY DEFAULT (0),
DEV_RET MONEY DEFAULT (0),
DEV_ICA MONEY DEFAULT (0),
DEV_COS MONEY DEFAULT (0),
DEV_FLE MONEY DEFAULT (0),
DEV_OTR MONEY DEFAULT (0),
DEV_FAL MONEY DEFAULT (0),
DEV_ANT MONEY DEFAULT (0),
DEV_SEG MONEY DEFAULT (0),
DEV_PAG MONEY DEFAULT (0),
DEV_IMP MONEY DEFAULT (0),
DEV_NET MONEY DEFAULT (0) NOT NULL,
DEV_PAR BIT DEFAULT (0) NOT NULL,
DEV_VEN VARCHAR(11),
DEV_CMS DECIMAL(14,4) DEFAULT (0),
DEV_CPC VARCHAR(3),
DEV_CTA VARCHAR(3),
DEV_VEH VARCHAR(10),
DEV_CUE VARCHAR(16),
DEV_CIU VARCHAR(8),
DEV_MOD VARCHAR(3),
DEV_SOB BIT DEFAULT (0) NOT NULL,
DEV_CC VARCHAR(3),
DEV_RIV MONEY DEFAULT (0),
DEV_EQV BIT DEFAULT (0),
DEV_EQT VARCHAR(3),
DEV_BOM MONEY DEFAULT (0),
DEV_ICO MONEY DEFAULT (0),
DEV_CSE MONEY DEFAULT (0),
DEV_BDI MONEY DEFAULT (0),
DEV_DIV MONEY DEFAULT (0),
DEV_IMV MONEY DEFAULT ((0)) NOT NULL,
DEV_RTC MONEY DEFAULT ((0)),
DEV_TRC DECIMAL(14,4) DEFAULT ((0)),
DEV_CRC VARCHAR(3),
DEV_IVO MONEY DEFAULT ((0)),
DEV_TAF DECIMAL(14,4) DEFAULT ((0)) NOT NULL,
DEV_CAF VARCHAR(3),
DEV_ARF MONEY DEFAULT ((0)) NOT NULL,
DEV_TAI DECIMAL(14,4) DEFAULT ((0)) NOT NULL,
DEV_CAI VARCHAR(3),
DEV_ARI MONEY DEFAULT ((0)) NOT NULL,
DEV_TKT MONEY DEFAULT ((0)),
DEV_EXC MONEY DEFAULT ((0)),
DEV_DVC MONEY DEFAULT ((0)),
DEV_IBA MONEY DEFAULT(0) NOT NULL,
DEV_ICU MONEY DEFAULT(0) NOT NULL,
DEV_IAT MONEY DEFAULT(0) NOT NULL,
DEV_TAT DECIMAL(14,4) DEFAULT(0) NOT NULL,
DEV_CAT VARCHAR(3),
DEV_TIB DECIMAL(14,4) DEFAULT(0) NOT NULL,
DEV_ART MONEY DEFAULT(0) NOT NULL,
DEV_ARB MONEY DEFAULT(0) NOT NULL
 CONSTRAINT PK_DEVOLUCIONES PRIMARY KEY CLUSTERED (DEV_NUM,DEV_TIP,DEV_CIA),
 CONSTRAINT CK__DEVOLUCIO__DEV_C__6FD49106 CHECK ((len([DEV_CIA]) > 0)),
 CONSTRAINT CK__DEVOLUCIO__DEV_C__70C8B53F CHECK ((len([DEV_CON]) > 0)),
 CONSTRAINT CK__DEVOLUCIO__DEV_T__6DEC4894 CHECK ((len([DEV_TIP]) > 0)),
 CONSTRAINT CK__DEVOLUCIO__DEV_T__72B0FDB1 CHECK ((len([DEV_TDC]) > 0)))
CREATE TABLE DOCSOPORTEDEV ( 
DSO_TIP VARCHAR(3) NOT NULL,
DSO_NUM INT DEFAULT ((0)) NOT NULL,
DSO_CIA CHAR(2) NOT NULL,
DSO_FEC SMALLDATETIME NOT NULL,
DSO_TDC VARCHAR(3) NOT NULL,
DSO_NDC INT DEFAULT ((0)) NOT NULL,
DSO_CDC CHAR(2) NOT NULL,
DSO_NIT VARCHAR(11) NOT NULL,
DSO_CON VARCHAR(3),
DSO_MOD VARCHAR(20),
DSO_FAC VARCHAR(15),
DSO_VAL DECIMAL(16,6) DEFAULT ((0)) NOT NULL,
DSO_DCT DECIMAL(16,6) DEFAULT ((0)),
DSO_RET DECIMAL(16,6) DEFAULT ((0)),
DSO_ICA DECIMAL(16,6) DEFAULT ((0)),
DSO_BOM DECIMAL(16,6) DEFAULT ((0)),
DSO_IAT DECIMAL(16,6) DEFAULT ((0)),
DSO_OTR DECIMAL(16,6) DEFAULT ((0)),
DSO_ODC DECIMAL(16,6) DEFAULT ((0)),
DSO_NET DECIMAL(16,6) DEFAULT ((0)),
DSO_CCT VARCHAR(3),
DSO_CUE VARCHAR(16),
DSO_NCP VARCHAR(11),
DSO_IMP DECIMAL(16,6) DEFAULT (0) NOT NULL
 CONSTRAINT PK_DOCSOPORTEDEV PRIMARY KEY CLUSTERED (DSO_TIP,DSO_NUM,DSO_CIA),
 CONSTRAINT CK_DOCSOPORTEDEVDSO_CDC CHECK ((len([DSO_CDC])>(0))),
 CONSTRAINT CK_DOCSOPORTEDEVDSO_CIA CHECK ((len([DSO_CIA])>(0))),
 CONSTRAINT CK_DOCSOPORTEDEVDSO_NIT CHECK ((len([DSO_NIT])>(0))),
 CONSTRAINT CK_DOCSOPORTEDEVDSO_TDC CHECK ((len([DSO_TDC])>(0))),
 CONSTRAINT CK_DOCSOPORTEDEVDSO_TIP CHECK ((len([DSO_TIP])>(0))))
CREATE TABLE DOCCUENTA ( 
DCC_NUM INT DEFAULT (0) NOT NULL,
DCC_TIP VARCHAR(3) NOT NULL,
DCC_CON VARCHAR(3) NOT NULL,
DCC_CIA CHAR(2) DEFAULT ('01') NOT NULL,
DCC_ITM SMALLINT DEFAULT (0) NOT NULL,
DCC_CUE VARCHAR(16) NOT NULL,
DCC_FEC SMALLDATETIME,
DCC_VAL MONEY DEFAULT (0),
DCC_NIT VARCHAR(11),
DCC_CC VARCHAR(3),
DCC_DET VARCHAR(100),
DCC_BAS MONEY DEFAULT (0)
 CONSTRAINT PK_DOCCUENTA PRIMARY KEY CLUSTERED (DCC_NUM,DCC_TIP,DCC_CON,DCC_CIA,DCC_ITM),
 CONSTRAINT CK__DOCCUENTA__DCC_C__0A888742 CHECK ((len([DCC_CON]) > 0)),
 CONSTRAINT CK__DOCCUENTA__DCC_C__0C70CFB4 CHECK ((len([DCC_CIA]) > 0)),
 CONSTRAINT CK__DOCCUENTA__DCC_C__0E591826 CHECK ((len([DCC_CUE]) > 0)),
 CONSTRAINT CK__DOCCUENTA__DCC_T__09946309 CHECK ((len([DCC_TIP]) > 0)))
CREATE TABLE DOCSOPORTE ( 
SOP_TIP VARCHAR(3) NOT NULL,
SOP_NUM INT DEFAULT ((0)) NOT NULL,
SOP_CIA CHAR(2) NOT NULL,
SOP_FEC SMALLDATETIME NOT NULL,
SOP_NIT VARCHAR(11) NOT NULL,
SOP_ADQ VARCHAR(11),
SOP_CON VARCHAR(3),
SOP_MED VARCHAR(3),
SOP_MET INT DEFAULT(0),
SOP_MOD VARCHAR(20),
SOP_FAC VARCHAR(15),
SOP_FFA SMALLDATETIME,
SOP_FVC SMALLDATETIME,
SOP_VAL DECIMAL(16,6) DEFAULT(0) NOT NULL,
SOP_DCT DECIMAL(16,6) DEFAULT(0) NOT NULL,
SOP_RET DECIMAL(16,6) DEFAULT(0) NOT NULL,
SOP_ICA DECIMAL(16,6) DEFAULT(0) NOT NULL,
SOP_BOM DECIMAL(16,6) DEFAULT(0) NOT NULL,
SOP_IAT DECIMAL(16,6) DEFAULT(0) NOT NULL,
SOP_OTR DECIMAL(16,6) DEFAULT(0) NOT NULL,
SOP_ODC DECIMAL(16,6) DEFAULT(0) NOT NULL,
SOP_NET DECIMAL(16,6) DEFAULT(0) NOT NULL,
SOP_DCS VARCHAR(250),
SOP_RES VARCHAR(3),
SOP_TDR VARCHAR(3) NOT NULL,
SOP_NDR INT DEFAULT(0) NOT NULL,
SOP_CDR CHAR(2) NOT NULL,
SOP_TDD VARCHAR(3),
SOP_NDD INT DEFAULT(0) NOT NULL,
SOP_CDD CHAR(2),
SOP_CCT VARCHAR(3),
SOP_CUE VARCHAR(16),
SOP_NCP VARCHAR(11),
SOP_IMP DECIMAL(16,6) DEFAULT(0) NOT NULL
 CONSTRAINT PK_DOCSOPORTE PRIMARY KEY CLUSTERED (SOP_TIP,SOP_NUM,SOP_CIA),
 CONSTRAINT CK_DOCSOPORTESOP_CDR CHECK ((len([SOP_CDR])>(0))),
 CONSTRAINT CK_DOCSOPORTESOP_CIA CHECK ((len([SOP_CIA])>(0))),
 CONSTRAINT CK_DOCSOPORTESOP_NIT CHECK ((len([SOP_NIT])>(0))),
 CONSTRAINT CK_DOCSOPORTESOP_TDR CHECK ((len([SOP_TDR])>(0))),
 CONSTRAINT CK_DOCSOPORTESOP_TIP CHECK ((len([SOP_TIP])>(0))))
CREATE TABLE DOCSOPORTEDET ( 
DET_TIP VARCHAR(3) NOT NULL,
DET_NUM INT DEFAULT ((0)) NOT NULL,
DET_CIA CHAR(2) NOT NULL,
DET_ITM INT DEFAULT ((0)) NOT NULL,
DET_COD VARCHAR(16) NOT NULL,
DET_DES VARCHAR(1000) NOT NULL,
DET_CAN DECIMAL(14,4) DEFAULT(0) NOT NULL,
DET_VUN DECIMAL(16,6) DEFAULT(0) NOT NULL,
DET_VAL DECIMAL(14,4) DEFAULT(0) NOT NULL,
DET_DCT DECIMAL(16,6) DEFAULT(0) NOT NULL,
DET_RET DECIMAL(16,6) DEFAULT(0) NOT NULL,
DET_ICA DECIMAL(16,6) DEFAULT(0) NOT NULL,
DET_BOM DECIMAL(16,6) DEFAULT(0) NOT NULL,
DET_IAT DECIMAL(16,6) DEFAULT(0) NOT NULL,
DET_PRT DECIMAL(16,6) DEFAULT(0) NOT NULL,
DET_PIC DECIMAL(16,6) DEFAULT(0) NOT NULL,
DET_PBO DECIMAL(16,6) DEFAULT(0) NOT NULL,
DET_PAT DECIMAL(16,6) DEFAULT(0) NOT NULL,
DET_PDC VARCHAR(3),
DET_CPR VARCHAR(3),
DET_CPI VARCHAR(3),
DET_CPB VARCHAR(3),
DET_CPA VARCHAR(3),
DET_CPD VARCHAR(3),
DET_TCO VARCHAR(3),
DET_NCO INT DEFAULT (0),
DET_CCO CHAR(2),
DET_ICO INT DEFAULT (0),
DET_CUE VARCHAR(16),
DET_NIT VARCHAR(11),
DET_CCT VARCHAR(3),
DET_AGE VARCHAR(9)
 CONSTRAINT PK_DOCSOPORTEDET PRIMARY KEY CLUSTERED (DET_TIP,DET_NUM,DET_CIA,DET_ITM),
 CONSTRAINT CK_DOCSOPORTEDETDET_CCO CHECK ((len([DET_CCO])>(0))),
 CONSTRAINT CK_DOCSOPORTEDETDET_CIA CHECK ((len([DET_CIA])>(0))),
 CONSTRAINT CK_DOCSOPORTEDETDET_CUE CHECK ((len([DET_CUE])>(0))),
 CONSTRAINT CK_DOCSOPORTEDETDET_DES CHECK ((len([DET_DES])>(0))),
 CONSTRAINT CK_DOCSOPORTEDETDET_NIT CHECK ((len([DET_NIT])>(0))),
 CONSTRAINT CK_DOCSOPORTEDETDET_TCO CHECK ((len([DET_TCO])>(0))),
 CONSTRAINT CK_DOCSOPORTEDETDET_TIP CHECK ((len([DET_TIP])>(0))))
CREATE TABLE ENTRADAS ( 
ENT_NUM INT DEFAULT (0) NOT NULL,
ENT_TIP VARCHAR(3) DEFAULT ('ENT') NOT NULL,
ENT_CIA CHAR(2) DEFAULT ('01') NOT NULL,
ENT_FEC SMALLDATETIME NOT NULL,
ENT_CON VARCHAR(3) NOT NULL,
ENT_NIT VARCHAR(11) NOT NULL,
ENT_TDC VARCHAR(3) DEFAULT ('ODC'),
ENT_DOC INT DEFAULT (0),
ENT_CDC CHAR(2) DEFAULT ('01'),
ENT_FAC VARCHAR(10),
ENT_FFA SMALLDATETIME,
ENT_FVC SMALLDATETIME,
ENT_VAL MONEY DEFAULT (0) NOT NULL,
ENT_DCT MONEY DEFAULT (0),
ENT_IVA MONEY DEFAULT (0),
ENT_RET MONEY DEFAULT (0),
ENT_ICA MONEY DEFAULT (0),
ENT_FLE MONEY DEFAULT (0),
ENT_OTR MONEY DEFAULT (0),
ENT_PAG MONEY DEFAULT (0),
ENT_IMP MONEY DEFAULT (0),
ENT_IFL MONEY DEFAULT (0),
ENT_NET MONEY DEFAULT (0) NOT NULL,
ENT_NFL VARCHAR(11),
ENT_MOD VARCHAR(3),
ENT_CXP BIT DEFAULT (0) NOT NULL,
ENT_RIV MONEY DEFAULT (0),
ENT_EQV BIT DEFAULT (0),
ENT_EQT VARCHAR(3),
ENT_BOM MONEY DEFAULT (0),
ENT_ICO MONEY DEFAULT (0),
ENT_FLP BIT DEFAULT ((0)),
ENT_IMV MONEY DEFAULT ((0)) NOT NULL,
ENT_RTC MONEY DEFAULT ((0)),
ENT_TRC DECIMAL(14,4) DEFAULT ((0)),
ENT_CRC VARCHAR(3),
ENT_IVO MONEY DEFAULT ((0)),
ENT_TDS VARCHAR(3),
ENT_NDS INT DEFAULT ((0)),
ENT_CDS CHAR(2),
ENT_IAT MONEY DEFAULT(0),
ENT_TAT DECIMAL(14,4) DEFAULT(0),
ENT_CAT VARCHAR(3),
ENT_TBO DECIMAL(14,4) DEFAULT(0),
ENT_IBA MONEY DEFAULT(0) NOT NULL,
ENT_ICU MONEY DEFAULT(0) NOT NULL
 CONSTRAINT PK_ENTRADAS PRIMARY KEY CLUSTERED (ENT_NUM,ENT_TIP,ENT_CIA),
 CONSTRAINT CK__ENTRADAS__ENT_CI__15FA39EE CHECK ((len([ENT_CIA]) > 0)),
 CONSTRAINT CK__ENTRADAS__ENT_CO__16EE5E27 CHECK ((len([ENT_CON]) > 0)),
 CONSTRAINT CK__ENTRADAS__ENT_NI__17E28260 CHECK ((len([ENT_NIT]) > 0)),
 CONSTRAINT CK__ENTRADAS__ENT_TI__1411F17C CHECK ((len([ENT_TIP]) > 0)))
CREATE TABLE FACCLI ( 
CLI_FAC INT DEFAULT (0) NOT NULL,
CLI_CIA CHAR(2) DEFAULT ('01') NOT NULL,
CLI_NIT VARCHAR(11)
 CONSTRAINT PK_FACCLI PRIMARY KEY CLUSTERED (CLI_FAC,CLI_CIA),
 CONSTRAINT CK__FACCLI__CLI_CIA__2BE97B0D CHECK ((len([CLI_CIA]) > 0)))
CREATE TABLE FACTURAS ( 
FAC_NUM INT DEFAULT (0) NOT NULL,
FAC_TIP VARCHAR(3) NOT NULL,
FAC_CIA CHAR(2) DEFAULT ('01') NOT NULL,
FAC_FEC SMALLDATETIME NOT NULL,
FAC_CON VARCHAR(3) NOT NULL,
FAC_CLI VARCHAR(11) NOT NULL,
FAC_AGE VARCHAR(9) DEFAULT ('N'),
FAC_VCE SMALLDATETIME,
FAC_PED INT DEFAULT (0),
FAC_REM INT DEFAULT (0),
FAC_COT INT DEFAULT (0),
FAC_CPD CHAR(2) DEFAULT ('01'),
FAC_CRM CHAR(2) DEFAULT ('01'),
FAC_VAL MONEY DEFAULT (0) NOT NULL,
FAC_IVA MONEY DEFAULT (0),
FAC_DCT MONEY DEFAULT (0),
FAC_RET MONEY DEFAULT (0),
FAC_ICA MONEY DEFAULT (0),
FAC_FLE MONEY DEFAULT (0),
FAC_COS MONEY DEFAULT (0),
FAC_FAL MONEY DEFAULT (0),
FAC_OTR MONEY DEFAULT (0),
FAC_PAG MONEY DEFAULT (0),
FAC_IMP MONEY DEFAULT (0),
FAC_NET MONEY DEFAULT (0) NOT NULL,
FAC_VDV MONEY DEFAULT (0),
FAC_VEN VARCHAR(11),
FAC_CMS DECIMAL(10,4) DEFAULT (0),
FAC_CPC VARCHAR(3),
FAC_FUP SMALLDATETIME,
FAC_MOD VARCHAR(3),
FAC_SOB BIT DEFAULT (0) NOT NULL,
FAC_TAS BIT DEFAULT (0) NOT NULL,
FAC_CIU VARCHAR(8),
FAC_RIV MONEY DEFAULT (0),
FAC_REF VARCHAR(50),
FAC_ICO MONEY DEFAULT (0),
FAC_CSE MONEY DEFAULT (0),
FAC_VEH VARCHAR(10),
FAC_BDI MONEY DEFAULT (0),
FAC_DIV MONEY DEFAULT (0),
FAC_RTC MONEY DEFAULT ((0)),
FAC_TRC DECIMAL(14,4) DEFAULT ((0)),
FAC_CRC VARCHAR(3),
FAC_IVO MONEY DEFAULT ((0)),
FAC_ARI MONEY DEFAULT ((0)),
FAC_TFE VARCHAR(3) DEFAULT ('1'),
FAC_FFE SMALLDATETIME,
FAC_TAF DECIMAL(14,4) DEFAULT ((0)) NOT NULL,
FAC_CAF VARCHAR(3),
FAC_ARF MONEY DEFAULT ((0)) NOT NULL,
FAC_TAI DECIMAL(14,4) DEFAULT ((0)) NOT NULL,
FAC_CAI VARCHAR(3),
FAC_ODC MONEY DEFAULT (0),
FAC_IAT MONEY DEFAULT(0) NOT NULL,
FAC_TAT DECIMAL(14,4) DEFAULT(0) NOT NULL,
FAC_CAT VARCHAR(3),
FAC_BOM MONEY DEFAULT(0) NOT NULL,
FAC_TIB DECIMAL(14,4) DEFAULT(0) NOT NULL,
FAC_CIB VARCHAR(3),
FAC_ART MONEY DEFAULT(0) NOT NULL,
FAC_ARB MONEY DEFAULT(0) NOT NULL,
FAC_OPE VARCHAR(10)
 CONSTRAINT PK_FACTURAS PRIMARY KEY CLUSTERED (FAC_NUM,FAC_TIP,FAC_CIA),
 CONSTRAINT CK__FACTURAS__FAC_CI__31A25463 CHECK ((len([FAC_CIA]) > 0)),
 CONSTRAINT CK__FACTURAS__FAC_CL__338A9CD5 CHECK ((len([FAC_CLI]) > 0)),
 CONSTRAINT CK__FACTURAS__FAC_CO__3296789C CHECK ((len([FAC_CON]) > 0)),
 CONSTRAINT CK__FACTURAS__FAC_TI__2FBA0BF1 CHECK ((len([FAC_TIP]) > 0)))
CREATE TABLE IFISICO ( 
FIS_TIP VARCHAR(3) DEFAULT ('FIS') NOT NULL,
FIS_NUM INT DEFAULT (0) NOT NULL,
FIS_CIA CHAR(2) DEFAULT ('01') NOT NULL,
FIS_FEC SMALLDATETIME NOT NULL,
FIS_CAN DECIMAL(14,4) DEFAULT (0),
FIS_SAL DECIMAL(14,4) DEFAULT (0),
FIS_VAL MONEY DEFAULT (0)
 CONSTRAINT PK_IFISICO PRIMARY KEY CLUSTERED (FIS_TIP,FIS_NUM,FIS_CIA),
 CONSTRAINT CK__IFISICO__FIS_CIA__4F32B74A CHECK ((len([FIS_CIA]) > 0)),
 CONSTRAINT CK__IFISICO__FIS_TIP__4C564A9F CHECK ((len([FIS_TIP]) > 0)))
CREATE TABLE IMORA ( 
MOR_TIP VARCHAR(3) DEFAULT ('MOR') NOT NULL,
MOR_NUM INT DEFAULT (0) NOT NULL,
MOR_CIA CHAR(2) DEFAULT ('01') NOT NULL,
MOR_FEC SMALLDATETIME NOT NULL,
MOR_TAS DECIMAL(14,4) DEFAULT (0),
MOR_GRA SMALLINT DEFAULT (0),
MOR_VAL MONEY DEFAULT (0),
MOR_IVA MONEY DEFAULT (0)
 CONSTRAINT PK_IMORA PRIMARY KEY CLUSTERED (MOR_TIP,MOR_NUM,MOR_CIA),
 CONSTRAINT CK__IMORA__MOR_CIA__58BC2184 CHECK ((len([MOR_CIA]) > 0)),
 CONSTRAINT CK__IMORA__MOR_TIP__55DFB4D9 CHECK ((len([MOR_TIP]) > 0)))
CREATE TABLE INFDOC ( 
DOC_TIP VARCHAR(3) NOT NULL,
DOC_NUM INT DEFAULT (0) NOT NULL,
DOC_CIA CHAR(2) DEFAULT ('01') NOT NULL,
DOC_CMP VARCHAR(3),
DOC_NCP INT DEFAULT (0),
DOC_DEV BIT DEFAULT (0) NOT NULL,
DOC_NDV INT DEFAULT (0),
DOC_FDV SMALLDATETIME,
DOC_MUL BIT DEFAULT (0) NOT NULL,
DOC_PAG VARCHAR(3),
DOC_OBS VARCHAR(250),
DOC_BAS MONEY DEFAULT (0),
DOC_BA1 MONEY DEFAULT (0),
DOC_BA2 MONEY DEFAULT (0),
DOC_POR DECIMAL(10,4) DEFAULT (0),
DOC_PO1 DECIMAL(10,4) DEFAULT (0),
DOC_PO2 DECIMAL(10,4) DEFAULT (0),
DOC_COP VARCHAR(3),
DOC_CO1 VARCHAR(8),
DOC_CO2 VARCHAR(3),
DOC_CUM BIT DEFAULT (0) NOT NULL,
DOC_FCU SMALLDATETIME,
DOC_EST VARCHAR(3),
DOC_FEC SMALLDATETIME,
DOC_CAN DECIMAL(14,4) DEFAULT (0),
DOC_USU VARCHAR(10),
DOC_KLR DECIMAL(14,4) DEFAULT (0),
DOC_TCU VARCHAR(3),
DOC_SUS VARCHAR(3),
DOC_CSU VARCHAR(3),
DOC_DCU VARCHAR(250),
DOC_CBO VARCHAR(3),
DOC_CVD INT DEFAULT ((0))
 CONSTRAINT PK_INFDOC PRIMARY KEY CLUSTERED (DOC_TIP,DOC_NUM,DOC_CIA),
 CONSTRAINT CK__INFDOC__DOC_CIA__62458BBE CHECK ((len([DOC_CIA]) > 0)),
 CONSTRAINT CK__INFDOC__DOC_TIP__5F691F13 CHECK ((len([DOC_TIP]) > 0)))
CREATE TABLE INGEGRCAJA ( 
CAJ_TIP VARCHAR(3) DEFAULT ('CIC') NOT NULL,
CAJ_NUM INT DEFAULT (0) NOT NULL,
CAJ_CIA CHAR(2) DEFAULT ('01') NOT NULL,
CAJ_FEC SMALLDATETIME NOT NULL,
CAJ_CON VARCHAR(3) NOT NULL,
CAJ_NIT VARCHAR(11),
CAJ_CC VARCHAR(3),
CAJ_CTA VARCHAR(3),
CAJ_CUE VARCHAR(16),
CAJ_TOT MONEY DEFAULT (0),
CAJ_DEB MONEY DEFAULT (0),
CAJ_CRE MONEY DEFAULT (0),
CAJ_AGE VARCHAR(9)
 CONSTRAINT PK_INGEGRCAJA PRIMARY KEY CLUSTERED (CAJ_TIP,CAJ_NUM,CAJ_CIA),
 CONSTRAINT CK__INGEGRCAJ__CAJ_C__74643BF9 CHECK ((len([CAJ_CIA]) > 0)),
 CONSTRAINT CK__INGEGRCAJ__CAJ_C__75586032 CHECK ((len([CAJ_CON]) > 0)),
 CONSTRAINT CK__INGEGRCAJ__CAJ_T__7187CF4E CHECK ((len([CAJ_TIP]) > 0)))
CREATE TABLE INVFISICO ( 
FIS_TAN VARCHAR(3) NOT NULL,
FIS_CIA CHAR(2) DEFAULT ('01') NOT NULL,
FIS_FEC SMALLDATETIME NOT NULL,
FIS_AFO DECIMAL(14,4) DEFAULT (0) NOT NULL,
FIS_SAL DECIMAL(14,4) DEFAULT (0),
FIS_VAL DECIMAL(14,4) DEFAULT (0),
FIS_AFA DECIMAL(14,4) DEFAULT (0),
FIS_AGU DECIMAL(14,4) DEFAULT (0)
 CONSTRAINT PK_INVFISICO PRIMARY KEY CLUSTERED (FIS_TAN,FIS_CIA,FIS_FEC),
 CONSTRAINT CK__INVFISICO__FIS_C__7CF981FA CHECK ((len([FIS_CIA]) > 0)),
 CONSTRAINT CK__INVFISICO__FIS_T__7B113988 CHECK ((len([FIS_TAN]) > 0)))
CREATE TABLE KARDEX ( 
KAR_TIP VARCHAR(3) NOT NULL,
KAR_NUM INT DEFAULT (0) NOT NULL,
KAR_CIA CHAR(2) DEFAULT ('01') NOT NULL,
KAR_ITM SMALLINT DEFAULT (1) NOT NULL,
KAR_DOC INT DEFAULT (0),
KAR_CDC CHAR(2) DEFAULT ('01'),
KAR_FEC SMALLDATETIME NOT NULL,
KAR_COD VARCHAR(16) NOT NULL,
KAR_SEC VARCHAR(3),
KAR_ENT DECIMAL(14,4) DEFAULT (0),
KAR_SAL DECIMAL(14,4) DEFAULT (0),
KAR_VAL MONEY DEFAULT (0) NOT NULL,
KAR_PRE MONEY DEFAULT (0),
KAR_IVA DECIMAL(10,4) DEFAULT (0),
KAR_VIE MONEY DEFAULT (0),
KAR_VIS MONEY DEFAULT (0),
KAR_DCT DECIMAL(10,4) DEFAULT (0),
KAR_VDE MONEY DEFAULT (0),
KAR_VDS MONEY DEFAULT (0),
KAR_CON VARCHAR(3),
KAR_CLI VARCHAR(11),
KAR_VEN VARCHAR(11),
KAR_CMS DECIMAL(10,4) DEFAULT (0),
KAR_CMC DECIMAL(10,4) DEFAULT (0),
KAR_TAN VARCHAR(3),
KAR_LOT VARCHAR(20),
KAR_REM VARCHAR(10),
KAR_PED INT DEFAULT (0),
KAR_COM BIT DEFAULT (0) NOT NULL,
KAR_SUR VARCHAR(3),
KAR_INI DECIMAL(17,4) DEFAULT (0),
KAR_FIN DECIMAL(17,4) DEFAULT (0),
KAR_TAS DECIMAL(10,4) DEFAULT (0),
KAR_NAC DECIMAL(10,4) DEFAULT (0),
KAR_DEP DECIMAL(10,4) DEFAULT (0),
KAR_MUN DECIMAL(10,4) DEFAULT (0),
KAR_SOL DECIMAL(10,4) DEFAULT (0),
KAR_UNI DECIMAL(14,4) DEFAULT (0),
KAR_IMP BIT DEFAULT (0) NOT NULL,
KAR_DCO VARCHAR(3),
KAR_REF VARCHAR(150) DEFAULT ('0'),
KAR_CIU VARCHAR(8),
KAR_CEN MONEY DEFAULT (0),
KAR_CSA MONEY DEFAULT (0),
KAR_PRT DECIMAL(10,4) DEFAULT (0),
KAR_RET MONEY DEFAULT (0),
KAR_RSA MONEY DEFAULT (0),
KAR_BAS MONEY DEFAULT (0),
KAR_USU VARCHAR(10),
KAR_OPE VARCHAR(11),
KAR_CRF VARCHAR(3),
KAR_CIC VARCHAR(3),
KAR_ICA MONEY DEFAULT (0),
KAR_PIC DECIMAL(10,4) DEFAULT (0),
KAR_GUI INT DEFAULT (0),
KAR_CGU CHAR(2),
KAR_ORD INT DEFAULT (0),
KAR_COC CHAR(2),
KAR_NCO VARCHAR(50),
KAR_FOC SMALLDATETIME,
KAR_AGE VARCHAR(9) DEFAULT ('N'),
KAR_ICO DECIMAL(14,4) DEFAULT (0),
KAR_TIC VARCHAR(3),
KAR_CUS MONEY DEFAULT (0),
KAR_TCV CHAR(1),
KAR_TCC CHAR(1),
KAR_DIV MONEY DEFAULT (0),
KAR_CC VARCHAR(3),
KAR_TIM DECIMAL(14,4) DEFAULT ((0)),
KAR_IMV DECIMAL(16,4) DEFAULT ((0)),
KAR_COB DECIMAL(14,4) DEFAULT ((0)),
KAR_IOB DECIMAL(16,4) DEFAULT ((0)),
KAR_RCO BIT DEFAULT ((0)),
KAR_CTB VARCHAR(3),
KAR_TIB DECIMAL(14,4) DEFAULT(0) NOT NULL,
KAR_IBA MONEY DEFAULT(0) NOT NULL,
KAR_CTU VARCHAR(3),
KAR_TIU DECIMAL(14,4) DEFAULT(0) NOT NULL,
KAR_ICU MONEY DEFAULT(0) NOT NULL,
KAR_IAT MONEY DEFAULT(0) NOT NULL,
KAR_TAT DECIMAL(14,4) DEFAULT(0) NOT NULL,
KAR_CAT VARCHAR(3),
KAR_BOM MONEY DEFAULT(0) NOT NULL,
KAR_TBO DECIMAL(14,4) DEFAULT(0) NOT NULL,
KAR_CIB VARCHAR(3)
 CONSTRAINT PK_KARDEX PRIMARY KEY CLUSTERED (KAR_TIP,KAR_NUM,KAR_CIA,KAR_ITM),
 CONSTRAINT CK__KARDEX__KAR_CIA__0777106D CHECK ((len([KAR_CIA]) > 0)),
 CONSTRAINT CK__KARDEX__KAR_COD__0B47A151 CHECK ((len([KAR_COD]) > 0)),
 CONSTRAINT CK__KARDEX__KAR_TIP__049AA3C2 CHECK ((len([KAR_TIP]) > 0)))
CREATE TABLE LEGALIZACION ( 
LEG_TIP VARCHAR(3) DEFAULT ('LEG') NOT NULL,
LEG_NUM INT DEFAULT (0) NOT NULL,
LEG_CIA CHAR(2) DEFAULT ('01') NOT NULL,
LEG_FEC SMALLDATETIME NOT NULL,
LEG_TPL VARCHAR(3) DEFAULT ('PLT'),
LEG_PLA INT DEFAULT (0) NOT NULL,
LEG_CPL CHAR(2) DEFAULT ('01') NOT NULL,
LEG_FPL SMALLDATETIME,
LEG_VEH VARCHAR(10),
LEG_NIT VARCHAR(11),
LEG_CDT VARCHAR(11),
LEG_CON VARCHAR(3) DEFAULT ('LEG'),
LEG_REG VARCHAR(20),
LEG_ORI VARCHAR(8),
LEG_DES VARCHAR(8),
LEG_CLI VARCHAR(11),
LEG_PRO VARCHAR(13),
LEG_VAL MONEY DEFAULT (0),
LEG_ANT MONEY DEFAULT (0),
LEG_GAL DECIMAL(14,4) DEFAULT (0),
LEG_COM MONEY DEFAULT (0),
LEG_REC MONEY DEFAULT (0),
LEG_ING MONEY DEFAULT (0),
LEG_RUT VARCHAR(3),
LEG_DTN VARCHAR(11),
LEG_KMI INT DEFAULT (0),
LEG_KMF INT DEFAULT (0),
LEG_CRE MONEY DEFAULT(0)
 CONSTRAINT PK_LEGALIZACION PRIMARY KEY CLUSTERED (LEG_TIP,LEG_NUM,LEG_CIA),
 CONSTRAINT CK__LEGALIZAC__LEG_C__2E90DD8E CHECK ((len([LEG_CIA]) > 0)),
 CONSTRAINT CK__LEGALIZAC__LEG_C__32616E72 CHECK ((len([LEG_CPL]) > 0)),
 CONSTRAINT CK__LEGALIZAC__LEG_T__2BB470E3 CHECK ((len([LEG_TIP]) > 0)))
CREATE TABLE LEGALIZACOMB ( 
COM_TIP VARCHAR(3) DEFAULT ('LEG') NOT NULL,
COM_NUM INT DEFAULT ((0)) NOT NULL,
COM_CIA CHAR(2) DEFAULT ('01') NOT NULL,
COM_ITM INT DEFAULT ((0)) NOT NULL,
COM_COD VARCHAR(3),
COM_DES VARCHAR(150) NOT NULL,
COM_CAN DECIMAL(14,4) DEFAULT ((0)) NOT NULL,
COM_VAL MONEY DEFAULT ((0)) NOT NULL
 CONSTRAINT PK_LEGALIZACOMB PRIMARY KEY CLUSTERED (COM_TIP,COM_NUM,COM_CIA,COM_ITM),
 CONSTRAINT CK_LEGALIZACOMBCOM_CIA CHECK ((len([COM_CIA])>(0))),
 CONSTRAINT CK_LEGALIZACOMBCOM_DES CHECK ((len([COM_DES])>(0))),
 CONSTRAINT CK_LEGALIZACOMBCOM_TIP CHECK ((len([COM_TIP])>(0))))
CREATE TABLE LEGOTROS ( 
LEG_TIP VARCHAR(3) DEFAULT ('LOE') NOT NULL,
LEG_NUM INT DEFAULT (0) NOT NULL,
LEG_CIA CHAR(2) DEFAULT ('01') NOT NULL,
LEG_FEC SMALLDATETIME NOT NULL,
LEG_VEH VARCHAR(10) NOT NULL,
LEG_NIT VARCHAR(11) NOT NULL,
LEG_CON VARCHAR(11),
LEG_REF VARCHAR(20),
LEG_PLA INT DEFAULT (0),
LEG_ORI VARCHAR(8),
LEG_DES VARCHAR(8),
LEG_VAL MONEY DEFAULT (0),
LEG_RUT VARCHAR(3),
LEG_EMP VARCHAR(11),
LEG_KMI INT DEFAULT (0),
LEG_KMF INT DEFAULT (0),
LEG_GAL DECIMAL(14,4) DEFAULT (0),
LEG_FAC INT DEFAULT (0),
LEG_CFA CHAR(2),
LEG_FFA SMALLDATETIME
 CONSTRAINT PK_LEGOTROS PRIMARY KEY CLUSTERED (LEG_TIP,LEG_NUM,LEG_CIA),
 CONSTRAINT CK__LEGOTROS__LEG_CI__3FBB6990 CHECK ((len([LEG_CIA]) > 0)),
 CONSTRAINT CK__LEGOTROS__LEG_NI__41A3B202 CHECK ((len([LEG_NIT]) > 0)),
 CONSTRAINT CK__LEGOTROS__LEG_TI__3CDEFCE5 CHECK ((len([LEG_TIP]) > 0)),
 CONSTRAINT CK__LEGOTROS__LEG_VE__40AF8DC9 CHECK ((len([LEG_VEH]) > 0)))
CREATE TABLE MOVSECCDET ( 
DET_TIP VARCHAR(3) NOT NULL,
DET_NUM INT DEFAULT (0) NOT NULL,
DET_CIA CHAR(2) NOT NULL,
DET_ITM INT DEFAULT (0) NOT NULL,
DET_FEC SMALLDATETIME NOT NULL,
DET_PRO VARCHAR(16) NOT NULL,
DET_SEC VARCHAR(3) NOT NULL,
DET_CAN DECIMAL(14,4) DEFAULT (0) NOT NULL,
DET_DEV DECIMAL(14,4) DEFAULT (0) NOT NULL,
DET_TDC VARCHAR(3) NOT NULL,
DET_NDC INT DEFAULT (0) NOT NULL,
DET_CDC CHAR(2) NOT NULL,
DET_HOR SMALLDATETIME NOT NULL,
DET_USU VARCHAR(8) NOT NULL,
DET_OBS VARCHAR(150)
 CONSTRAINT PK_MOVSECCDET PRIMARY KEY CLUSTERED (DET_TIP,DET_NUM,DET_CIA,DET_ITM),
 CONSTRAINT CK_MOVSECCDETDET_CDC CHECK ((len([DET_CDC]) > 0)),
 CONSTRAINT CK_MOVSECCDETDET_CIA CHECK ((len([DET_CIA]) > 0)),
 CONSTRAINT CK_MOVSECCDETDET_PRO CHECK ((len([DET_PRO]) > 0)),
 CONSTRAINT CK_MOVSECCDETDET_SEC CHECK ((len([DET_SEC]) > 0)),
 CONSTRAINT CK_MOVSECCDETDET_TDC CHECK ((len([DET_TDC]) > 0)),
 CONSTRAINT CK_MOVSECCDETDET_TIP CHECK ((len([DET_TIP]) > 0)),
 CONSTRAINT CK_MOVSECCDETDET_USU CHECK ((len([DET_USU]) > 0)))
CREATE TABLE MOVSECCION ( 
SEC_TIP VARCHAR(3) NOT NULL,
SEC_NUM INT DEFAULT (0) NOT NULL,
SEC_CIA CHAR(2) NOT NULL,
SEC_ITM INT DEFAULT (0) NOT NULL,
SEC_PRO VARCHAR(16) NOT NULL,
SEC_COD VARCHAR(3) NOT NULL,
SEC_CAN DECIMAL(14,4) DEFAULT (0) NOT NULL,
SEC_ENT DECIMAL(14,4) DEFAULT (0) NOT NULL,
SEC_DEV DECIMAL(14,4) DEFAULT (0) NOT NULL
 CONSTRAINT PK_MOVSECCION PRIMARY KEY CLUSTERED (SEC_TIP,SEC_NUM,SEC_CIA,SEC_ITM),
 CONSTRAINT CK_MOVSECCIONSEC_CIA CHECK ((len([SEC_CIA]) > 0)),
 CONSTRAINT CK_MOVSECCIONSEC_COD CHECK ((len([SEC_COD]) > 0)),
 CONSTRAINT CK_MOVSECCIONSEC_PRO CHECK ((len([SEC_PRO]) > 0)),
 CONSTRAINT CK_MOVSECCIONSEC_TIP CHECK ((len([SEC_TIP]) > 0)))
CREATE TABLE MOVSERIAL ( 
MOV_TIP VARCHAR(3) NOT NULL,
MOV_DOC INT DEFAULT (0) NOT NULL,
MOV_CIA CHAR(2) DEFAULT ('01') NOT NULL,
MOV_LIN SMALLINT DEFAULT (0) NOT NULL,
MOV_COD VARCHAR(16) NOT NULL,
MOV_NUM VARCHAR(20) NOT NULL,
MOV_ITM SMALLINT DEFAULT (0),
MOV_SEC VARCHAR(3),
MOV_MOV VARCHAR(3),
MOV_FEC SMALLDATETIME,
MOV_OBS VARCHAR(50),
MOV_DCM VARCHAR(10)
 CONSTRAINT PK_MOVSERIAL PRIMARY KEY CLUSTERED (MOV_TIP,MOV_DOC,MOV_CIA,MOV_LIN),
 CONSTRAINT CK__MOVSERIAL__MOV_C__4944D3CA CHECK ((len([MOV_CIA]) > 0)),
 CONSTRAINT CK__MOVSERIAL__MOV_C__4B2D1C3C CHECK ((len([MOV_COD]) > 0)),
 CONSTRAINT CK__MOVSERIAL__MOV_N__4C214075 CHECK ((len([MOV_NUM]) > 0)),
 CONSTRAINT CK__MOVSERIAL__MOV_T__4668671F CHECK ((len([MOV_TIP]) > 0)))
CREATE TABLE MUD_BODEGAS ( 
BOD_TIP VARCHAR(3) NOT NULL,
BOD_NUM INT DEFAULT (0) NOT NULL,
BOD_CIA CHAR(2) DEFAULT ('01') NOT NULL,
BOD_ITM INT DEFAULT (0) NOT NULL,
BOD_COD VARCHAR(3) NOT NULL,
BOD_DIR VARCHAR(150) NOT NULL,
BOD_INI SMALLDATETIME NOT NULL,
BOD_FIN SMALLDATETIME,
BOD_VAL MONEY DEFAULT (0) NOT NULL,
BOD_IVA MONEY DEFAULT (0) NOT NULL,
BOD_SEG MONEY DEFAULT (0) NOT NULL,
BOD_TFA VARCHAR(3) DEFAULT ('FCR') NOT NULL,
BOD_FAC INT DEFAULT (0) NOT NULL,
BOD_CFA CHAR(2) DEFAULT ('00') NOT NULL,
BOD_OBS VARCHAR(250),
BOD_USU VARCHAR(10) NOT NULL,
BOD_BG2 VARCHAR(3),
BOD_BG3 VARCHAR(3)
 CONSTRAINT PK_MUD_BODEGAS PRIMARY KEY CLUSTERED (BOD_TIP,BOD_NUM,BOD_CIA,BOD_ITM),
 CONSTRAINT CK_MUD_BODEGASBOD_CFA CHECK ((len([BOD_CFA]) > 0)),
 CONSTRAINT CK_MUD_BODEGASBOD_CIA CHECK ((len([BOD_CIA]) > 0)),
 CONSTRAINT CK_MUD_BODEGASBOD_COD CHECK ((len([BOD_COD]) > 0)),
 CONSTRAINT CK_MUD_BODEGASBOD_DIR CHECK ((len([BOD_DIR]) > 0)),
 CONSTRAINT CK_MUD_BODEGASBOD_TFA CHECK ((len([BOD_TFA]) > 0)),
 CONSTRAINT CK_MUD_BODEGASBOD_TIP CHECK ((len([BOD_TIP]) > 0)),
 CONSTRAINT CK_MUD_BODEGASBOD_USU CHECK ((len([BOD_USU]) > 0)))
CREATE TABLE MUD_DETALLE ( 
DET_TIP VARCHAR(3) NOT NULL,
DET_NUM INT DEFAULT (0) NOT NULL,
DET_CIA CHAR(2) DEFAULT ('01') NOT NULL,
DET_ITM INT DEFAULT (0) NOT NULL,
DET_DES VARCHAR(250) NOT NULL,
DET_CAN DECIMAL(14,4) DEFAULT (0) NOT NULL,
DET_EST VARCHAR(10) NOT NULL,
DET_OBS VARCHAR(150)
 CONSTRAINT PK_MUD_DETALLE PRIMARY KEY CLUSTERED (DET_TIP,DET_NUM,DET_CIA,DET_ITM),
 CONSTRAINT CK_MUD_DETALLEDET_CIA CHECK ((len([DET_CIA]) > 0)),
 CONSTRAINT CK_MUD_DETALLEDET_DES CHECK ((len([DET_DES]) > 0)),
 CONSTRAINT CK_MUD_DETALLEDET_EST CHECK ((len([DET_EST]) > 0)),
 CONSTRAINT CK_MUD_DETALLEDET_TIP CHECK ((len([DET_TIP]) > 0)))
CREATE TABLE MUD_EMBALAJES ( 
EMB_TIP VARCHAR(3) NOT NULL,
EMB_NUM INT DEFAULT (0) NOT NULL,
EMB_CIA CHAR(2) DEFAULT ('01') NOT NULL,
EMB_ORD INT DEFAULT (0) NOT NULL,
EMB_FEC SMALLDATETIME NOT NULL,
EMB_VAL MONEY DEFAULT (0) NOT NULL,
EMB_TSA VARCHAR(3),
EMB_NSA INT DEFAULT (0) NOT NULL,
EMB_CSA CHAR(2),
EMB_TDS VARCHAR(3),
EMB_NDS INT DEFAULT (0) NOT NULL,
EMB_CDS CHAR(2),
EMB_DEV BIT DEFAULT (0) NOT NULL,
EMB_OBS VARCHAR(250),
EMB_ALM VARCHAR(150),
EMB_SUP VARCHAR(150),
EMB_USU VARCHAR(10) NOT NULL
 CONSTRAINT PK_MUD_EMBALAJES PRIMARY KEY CLUSTERED (EMB_TIP,EMB_NUM,EMB_CIA,EMB_ORD),
 CONSTRAINT CK_MUD_EMBALAJESEMB_CIA CHECK ((len([EMB_CIA]) > 0)),
 CONSTRAINT CK_MUD_EMBALAJESEMB_TIP CHECK ((len([EMB_TIP]) > 0)),
 CONSTRAINT CK_MUD_EMBALAJESEMB_USU CHECK ((len([EMB_USU]) > 0)))
CREATE TABLE MUD_EMBDETALLE ( 
DET_TIP VARCHAR(3) NOT NULL,
DET_NUM INT DEFAULT (0) NOT NULL,
DET_CIA CHAR(2) DEFAULT ('01') NOT NULL,
DET_ORD INT DEFAULT (0) NOT NULL,
DET_ITM INT DEFAULT (0) NOT NULL,
DET_COD VARCHAR(16) DEFAULT ('0') NOT NULL,
DET_DES VARCHAR(150) NOT NULL,
DET_CAN DECIMAL(14,4) DEFAULT (0) NOT NULL,
DET_DEV DECIMAL(14,4) DEFAULT (0) NOT NULL
 CONSTRAINT PK_MUD_EMBDETALLE PRIMARY KEY CLUSTERED (DET_TIP,DET_NUM,DET_CIA,DET_ORD,DET_ITM),
 CONSTRAINT CK_MUD_EMBDETALLEDET_CIA CHECK ((len([DET_CIA]) > 0)),
 CONSTRAINT CK_MUD_EMBDETALLEDET_COD CHECK ((len([DET_COD]) > 0)),
 CONSTRAINT CK_MUD_EMBDETALLEDET_DES CHECK ((len([DET_DES]) > 0)),
 CONSTRAINT CK_MUD_EMBDETALLEDET_TIP CHECK ((len([DET_TIP]) > 0)))
CREATE TABLE MUD_EMPACADORES ( 
EMP_TIP VARCHAR(3) NOT NULL,
EMP_NUM INT DEFAULT (0) NOT NULL,
EMP_CIA CHAR(2) DEFAULT ('01') NOT NULL,
EMP_ORD INT DEFAULT (0) NOT NULL,
EMP_ITM INT DEFAULT (0) NOT NULL,
EMP_NOM VARCHAR(150) NOT NULL,
EMP_ID VARCHAR(11),
EMP_SER VARCHAR(10),
EMP_HOR VARCHAR(50),
EMP_TAR DECIMAL(14,4) DEFAULT (0)
 CONSTRAINT PK_MUD_EMPACADORES PRIMARY KEY CLUSTERED (EMP_TIP,EMP_NUM,EMP_CIA,EMP_ORD,EMP_ITM),
 CONSTRAINT CK_MUD_EMPACADORESEMP_CIA CHECK ((len([EMP_CIA]) > 0)),
 CONSTRAINT CK_MUD_EMPACADORESEMP_NOM CHECK ((len([EMP_NOM]) > 0)),
 CONSTRAINT CK_MUD_EMPACADORESEMP_TIP CHECK ((len([EMP_TIP]) > 0)))
CREATE TABLE MUD_NOVEDADES ( 
NOV_TIP VARCHAR(3) NOT NULL,
NOV_NUM INT DEFAULT (0) NOT NULL,
NOV_CIA CHAR(2) DEFAULT ('01') NOT NULL,
NOV_ITM INT DEFAULT (0) NOT NULL,
NOV_FEC SMALLDATETIME NOT NULL,
NOV_DES VARCHAR(250) NOT NULL,
NOV_CON VARCHAR(10),
NOV_CAN DECIMAL(14,4) DEFAULT (0) NOT NULL,
NOV_NOM VARCHAR(150)
 CONSTRAINT PK_MUD_NOVEDADES PRIMARY KEY CLUSTERED (NOV_TIP,NOV_NUM,NOV_CIA,NOV_ITM),
 CONSTRAINT CK_MUD_NOVEDADESNOV_CIA CHECK ((len([NOV_CIA]) > 0)),
 CONSTRAINT CK_MUD_NOVEDADESNOV_DES CHECK ((len([NOV_DES]) > 0)),
 CONSTRAINT CK_MUD_NOVEDADESNOV_TIP CHECK ((len([NOV_TIP]) > 0)))
CREATE TABLE MUD_OPERARIOS ( 
OPE_TIP VARCHAR(3) NOT NULL,
OPE_NUM INT DEFAULT (0) NOT NULL,
OPE_CIA CHAR(2) DEFAULT ('01') NOT NULL,
OPE_ITM INT DEFAULT (0) NOT NULL,
OPE_NOM VARCHAR(150) NOT NULL,
OPE_ID VARCHAR(11) DEFAULT ('0') NOT NULL,
OPE_CLA VARCHAR(20) NOT NULL,
OPE_SER VARCHAR(10),
OPE_HOR VARCHAR(50),
OPE_TAR DECIMAL(14,4) DEFAULT (0),
OPE_BAS MONEY DEFAULT (0)
 CONSTRAINT PK_MUD_OPERARIOS PRIMARY KEY CLUSTERED (OPE_TIP,OPE_NUM,OPE_CIA,OPE_ITM),
 CONSTRAINT CK_MUD_OPERARIOSOPE_CIA CHECK ((len([OPE_CIA]) > 0)),
 CONSTRAINT CK_MUD_OPERARIOSOPE_CLA CHECK ((len([OPE_CLA]) > 0)),
 CONSTRAINT CK_MUD_OPERARIOSOPE_ID CHECK ((len([OPE_ID]) > 0)),
 CONSTRAINT CK_MUD_OPERARIOSOPE_NOM CHECK ((len([OPE_NOM]) > 0)),
 CONSTRAINT CK_MUD_OPERARIOSOPE_TIP CHECK ((len([OPE_TIP]) > 0)))
CREATE TABLE MUDANZAS ( 
MUD_TIP VARCHAR(3) NOT NULL,
MUD_NUM INT DEFAULT (0) NOT NULL,
MUD_CIA CHAR(2) DEFAULT ('01') NOT NULL,
MUD_FEC SMALLDATETIME NOT NULL,
MUD_FDE SMALLDATETIME NOT NULL,
MUD_MOD VARCHAR(10) DEFAULT ('TRANSPORTE') NOT NULL,
MUD_VEN VARCHAR(11) NOT NULL,
MUD_CLI VARCHAR(11) NOT NULL,
MUD_AGE VARCHAR(9) DEFAULT ('N'),
MUD_VEH VARCHAR(10) NOT NULL,
MUD_CDT VARCHAR(11) NOT NULL,
MUD_EMP VARCHAR(11),
MUD_NEM VARCHAR(150),
MUD_DOR VARCHAR(250) NOT NULL,
MUD_ORI VARCHAR(8) NOT NULL,
MUD_TRC VARCHAR(10) DEFAULT ('CASA') NOT NULL,
MUD_TOR VARCHAR(20),
MUD_CLR VARCHAR(20),
MUD_DDE VARCHAR(250) NOT NULL,
MUD_DES VARCHAR(8) NOT NULL,
MUD_TRD VARCHAR(10) DEFAULT ('CASA') NOT NULL,
MUD_TLD VARCHAR(20),
MUD_CLD VARCHAR(20),
MUD_CAN INT DEFAULT (0) NOT NULL,
MUD_CCL INT DEFAULT (0) NOT NULL,
MUD_UND INT DEFAULT (0) NOT NULL,
MUD_DEC MONEY DEFAULT (0) NOT NULL,
MUD_TRA MONEY DEFAULT (0) NOT NULL,
MUD_SEG MONEY DEFAULT (0) NOT NULL,
MUD_BOD MONEY DEFAULT (0) NOT NULL,
MUD_SGB MONEY DEFAULT (0) NOT NULL,
MUD_OTR MONEY DEFAULT (0) NOT NULL,
MUD_TRM VARCHAR(3) DEFAULT ('RMT') NOT NULL,
MUD_REM INT DEFAULT (0) NOT NULL,
MUD_CRM CHAR(2) DEFAULT ('01') NOT NULL,
MUD_TFA VARCHAR(3) DEFAULT ('FCR') NOT NULL,
MUD_FAC INT DEFAULT (0) NOT NULL,
MUD_CFA CHAR(2) DEFAULT ('00') NOT NULL,
MUD_FFA SMALLDATETIME,
MUD_AUT VARCHAR(50),
MUD_PED INT DEFAULT (0) NOT NULL,
MUD_CPE CHAR(2),
MUD_IMG VARCHAR(100)
 CONSTRAINT PK_MUDANZAS PRIMARY KEY CLUSTERED (MUD_TIP,MUD_NUM,MUD_CIA),
 CONSTRAINT CK_MUDANZASMUD_CDT CHECK ((len([MUD_CDT]) > 0)),
 CONSTRAINT CK_MUDANZASMUD_CFA CHECK ((len([MUD_CFA]) > 0)),
 CONSTRAINT CK_MUDANZASMUD_CIA CHECK ((len([MUD_CIA]) > 0)),
 CONSTRAINT CK_MUDANZASMUD_CLI CHECK ((len([MUD_CLI]) > 0)),
 CONSTRAINT CK_MUDANZASMUD_CRM CHECK ((len([MUD_CRM]) > 0)),
 CONSTRAINT CK_MUDANZASMUD_DDE CHECK ((len([MUD_DDE]) > 0)),
 CONSTRAINT CK_MUDANZASMUD_DES CHECK ((len([MUD_DES]) > 0)),
 CONSTRAINT CK_MUDANZASMUD_DOR CHECK ((len([MUD_DOR]) > 0)),
 CONSTRAINT CK_MUDANZASMUD_MOD CHECK ((len([MUD_MOD]) > 0)),
 CONSTRAINT CK_MUDANZASMUD_ORI CHECK ((len([MUD_ORI]) > 0)),
 CONSTRAINT CK_MUDANZASMUD_TFA CHECK ((len([MUD_TFA]) > 0)),
 CONSTRAINT CK_MUDANZASMUD_TIP CHECK ((len([MUD_TIP]) > 0)),
 CONSTRAINT CK_MUDANZASMUD_TRC CHECK ((len([MUD_TRC]) > 0)),
 CONSTRAINT CK_MUDANZASMUD_TRD CHECK ((len([MUD_TRD]) > 0)),
 CONSTRAINT CK_MUDANZASMUD_TRM CHECK ((len([MUD_TRM]) > 0)),
 CONSTRAINT CK_MUDANZASMUD_VEH CHECK ((len([MUD_VEH]) > 0)),
 CONSTRAINT CK_MUDANZASMUD_VEN CHECK ((len([MUD_VEN]) > 0)))
CREATE TABLE MULTAS ( 
MUL_TIP VARCHAR(3) DEFAULT ('MUL') NOT NULL,
MUL_NUM INT DEFAULT (0) NOT NULL,
MUL_CIA CHAR(2) DEFAULT ('01') NOT NULL,
MUL_FEC SMALLDATETIME NOT NULL,
MUL_TPL VARCHAR(3) DEFAULT ('PLT') NOT NULL,
MUL_PLA INT DEFAULT (0) NOT NULL,
MUL_CPL CHAR(2) DEFAULT ('01') NOT NULL,
MUL_NIT VARCHAR(11) NOT NULL,
MUL_VEH VARCHAR(10) NOT NULL,
MUL_PUE VARCHAR(3),
MUL_VAL MONEY DEFAULT (0) NOT NULL,
MUL_APL MONEY DEFAULT (0),
MUL_DOC INT DEFAULT (0)
 CONSTRAINT PK_MULTAS PRIMARY KEY CLUSTERED (MUL_TIP,MUL_NUM,MUL_CIA),
 CONSTRAINT CK__MULTAS__MUL_CIA__53C2623D CHECK ((len([MUL_CIA]) > 0)),
 CONSTRAINT CK__MULTAS__MUL_CPL__5887175A CHECK ((len([MUL_CPL]) > 0)),
 CONSTRAINT CK__MULTAS__MUL_NIT__597B3B93 CHECK ((len([MUL_NIT]) > 0)),
 CONSTRAINT CK__MULTAS__MUL_TIP__50E5F592 CHECK ((len([MUL_TIP]) > 0)),
 CONSTRAINT CK__MULTAS__MUL_TPL__55AAAAAF CHECK ((len([MUL_TPL]) > 0)),
 CONSTRAINT CK__MULTAS__MUL_VEH__5A6F5FCC CHECK ((len([MUL_VEH]) > 0)))
CREATE TABLE NOTAS ( 
NOT_NUM INT DEFAULT (0) NOT NULL,
NOT_TIP VARCHAR(3) NOT NULL,
NOT_CIA CHAR(2) DEFAULT ('01') NOT NULL,
NOT_FEC SMALLDATETIME NOT NULL,
NOT_CON VARCHAR(3) NOT NULL,
NOT_CLI VARCHAR(11) NOT NULL,
NOT_AGE VARCHAR(9) DEFAULT ('N'),
NOT_VCE SMALLDATETIME,
NOT_REF VARCHAR(10),
NOT_TDC VARCHAR(3),
NOT_DOC INT DEFAULT (0),
NOT_CDC CHAR(2) DEFAULT ('01'),
NOT_VAL MONEY DEFAULT (0),
NOT_IVA MONEY DEFAULT (0),
NOT_ICA MONEY DEFAULT (0),
NOT_RET MONEY DEFAULT (0),
NOT_COS MONEY DEFAULT (0),
NOT_NET MONEY DEFAULT (0) NOT NULL,
NOT_VEN VARCHAR(11),
NOT_CMS DECIMAL(10,4) DEFAULT (0),
NOT_CPC VARCHAR(3),
NOT_CHE VARCHAR(20),
NOT_CIU VARCHAR(8),
NOT_CTA VARCHAR(3),
NOT_PAR BIT DEFAULT (0) NOT NULL,
NOT_CAJ MONEY DEFAULT (0),
NOT_PRO VARCHAR(16),
NOT_SAN MONEY DEFAULT (0),
NOT_RTC MONEY DEFAULT ((0)),
NOT_TRC DECIMAL(14,4) DEFAULT ((0)),
NOT_CRC VARCHAR(3),
NOT_CFE INT DEFAULT (0),
NOT_TFE INT DEFAULT(0)
 CONSTRAINT PK_NOTAS PRIMARY KEY CLUSTERED (NOT_NUM,NOT_TIP,NOT_CIA),
 CONSTRAINT CK__NOTAS__NOT_CIA__6304A5CD CHECK ((len([NOT_CIA]) > 0)),
 CONSTRAINT CK__NOTAS__NOT_CLI__64ECEE3F CHECK ((len([NOT_CLI]) > 0)),
 CONSTRAINT CK__NOTAS__NOT_CON__63F8CA06 CHECK ((len([NOT_CON]) > 0)),
 CONSTRAINT CK__NOTAS__NOT_TIP__611C5D5B CHECK ((len([NOT_TIP]) > 0)))
CREATE TABLE OPAGO ( 
ODP_NUM INT DEFAULT (0) NOT NULL,
ODP_TIP VARCHAR(3) DEFAULT ('ODP') NOT NULL,
ODP_CIA CHAR(2) DEFAULT ('01') NOT NULL,
ODP_FEC SMALLDATETIME NOT NULL,
ODP_TPL VARCHAR(3) DEFAULT ('PLT') NOT NULL,
ODP_PLA INT DEFAULT (0) NOT NULL,
ODP_CPL CHAR(2) DEFAULT ('01') NOT NULL,
ODP_REF VARCHAR(20),
ODP_VEH VARCHAR(10) NOT NULL,
ODP_NIT VARCHAR(11) NOT NULL,
ODP_CON VARCHAR(3),
ODP_VAL MONEY DEFAULT (0),
ODP_DCT MONEY DEFAULT (0),
ODP_TOT MONEY DEFAULT (0),
ODP_ICA MONEY DEFAULT (0),
ODP_RET MONEY DEFAULT (0),
ODP_SEG MONEY DEFAULT (0),
ODP_ANT MONEY DEFAULT (0),
ODP_FAL MONEY DEFAULT (0),
ODP_OTR MONEY DEFAULT (0),
ODP_PAG MONEY DEFAULT (0),
ODP_NET MONEY DEFAULT (0) NOT NULL,
ODP_FLE MONEY DEFAULT (0),
ODP_REM INT DEFAULT (0),
ODP_CRM CHAR(2),
ODP_EGR INT DEFAULT ((-1)),
ODP_CEG CHAR(2),
ODP_FEG SMALLDATETIME,
ODP_CHE VARCHAR(20),
ODP_CXP BIT DEFAULT (0) NOT NULL,
ODP_VES MONEY DEFAULT (0),
ODP_BOM MONEY DEFAULT (0),
ODP_MUL MONEY DEFAULT (0),
ODP_RTC MONEY DEFAULT ((0)),
ODP_TRC DECIMAL(14,4) DEFAULT ((0)),
ODP_CRC VARCHAR(3),
ODP_IAT MONEY DEFAULT ((0)),
ODP_TAT DECIMAL(14,4) DEFAULT ((0)),
ODP_CAT VARCHAR(3),
ODP_NDS INT DEFAULT(0),
ODP_CDS CHAR(2)
 CONSTRAINT PK_OPAGO PRIMARY KEY CLUSTERED (ODP_NUM,ODP_TIP,ODP_CIA),
 CONSTRAINT CK__OPAGO__ODP_CIA__770B9E7A CHECK ((len([ODP_CIA]) > 0)),
 CONSTRAINT CK__OPAGO__ODP_CPL__7BD05397 CHECK ((len([ODP_CPL]) > 0)),
 CONSTRAINT CK__OPAGO__ODP_NIT__7DB89C09 CHECK ((len([ODP_NIT]) > 0)),
 CONSTRAINT CK__OPAGO__ODP_TIP__75235608 CHECK ((len([ODP_TIP]) > 0)),
 CONSTRAINT CK__OPAGO__ODP_TPL__78F3E6EC CHECK ((len([ODP_TPL]) > 0)),
 CONSTRAINT CK__OPAGO__ODP_VEH__7CC477D0 CHECK ((len([ODP_VEH]) > 0)))
CREATE TABLE OPMULTAS ( 
OPM_TIP VARCHAR(3) NOT NULL,
OPM_NUM INT DEFAULT (0) NOT NULL,
OPM_CIA CHAR(2) NOT NULL,
OPM_ITM INT DEFAULT (0) NOT NULL,
OPM_FEC SMALLDATETIME NOT NULL,
OPM_TMU VARCHAR(3) NOT NULL,
OPM_MUL INT DEFAULT (0) NOT NULL,
OPM_CMU CHAR(2) NOT NULL,
OPM_VAL MONEY DEFAULT (0) NOT NULL
 CONSTRAINT PK_OPMULTAS PRIMARY KEY CLUSTERED (OPM_TIP,OPM_NUM,OPM_CIA,OPM_ITM),
 CONSTRAINT CK_OPMULTASOPM_CIA CHECK ((len([OPM_CIA]) > 0)),
 CONSTRAINT CK_OPMULTASOPM_CMU CHECK ((len([OPM_CMU]) > 0)),
 CONSTRAINT CK_OPMULTASOPM_TIP CHECK ((len([OPM_TIP]) > 0)),
 CONSTRAINT CK_OPMULTASOPM_TMU CHECK ((len([OPM_TMU]) > 0)))
CREATE TABLE ORDVIAJES ( 
ODC_TIP VARCHAR(3) DEFAULT ('OCV') NOT NULL,
ODC_NUM INT DEFAULT ((0)) NOT NULL,
ODC_CIA CHAR(2) NOT NULL,
ODC_FEC SMALLDATETIME NOT NULL,
ODC_VEH VARCHAR(10) NOT NULL,
ODC_CON VARCHAR(11) NOT NULL,
ODC_TRA VARCHAR(10),
ODC_ORI VARCHAR(8) NOT NULL,
ODC_DES VARCHAR(8) NOT NULL,
ODC_VAL MONEY DEFAULT ((0)),
ODC_MUC INT DEFAULT ((0)) NOT NULL,
ODC_CMC CHAR(2),
ODC_NRM VARCHAR(20)
 CONSTRAINT PK_ORDVIAJES PRIMARY KEY CLUSTERED (ODC_TIP,ODC_NUM,ODC_CIA),
 CONSTRAINT CK_ORDVIAJESODC_CIA CHECK ((len([ODC_CIA])>(0))),
 CONSTRAINT CK_ORDVIAJESODC_CON CHECK ((len([ODC_CON])>(0))),
 CONSTRAINT CK_ORDVIAJESODC_DES CHECK ((len([ODC_DES])>(0))),
 CONSTRAINT CK_ORDVIAJESODC_ORI CHECK ((len([ODC_ORI])>(0))),
 CONSTRAINT CK_ORDVIAJESODC_TIP CHECK ((len([ODC_TIP])>(0))),
 CONSTRAINT CK_ORDVIAJESODC_VEH CHECK ((len([ODC_VEH])>(0))))
CREATE TABLE PAGOS ( 
PAG_NUM INT DEFAULT (0) NOT NULL,
PAG_TIP VARCHAR(3) NOT NULL,
PAG_CIA CHAR(2) DEFAULT ('01') NOT NULL,
PAG_ITM SMALLINT DEFAULT (0) NOT NULL,
PAG_FEC SMALLDATETIME NOT NULL,
PAG_FOR VARCHAR(3) DEFAULT ('EFE') NOT NULL,
PAG_VAL MONEY DEFAULT (0) NOT NULL,
PAG_BAN VARCHAR(3),
PAG_CHE VARCHAR(20),
PAG_REF VARCHAR(50),
PAG_CTA VARCHAR(3),
PAG_CIU VARCHAR(8),
PAG_DCT MONEY DEFAULT (0),
PAG_DOC VARCHAR(20),
PAG_NIT VARCHAR(11),
PAG_USU VARCHAR(10),
PAG_AGE VARCHAR(9),
PAG_PRO VARCHAR(16),
PAG_CAN DECIMAL(14,4) DEFAULT ((0)),
PAG_VEH VARCHAR(10),
PAG_NVH VARCHAR(15),
PAG_TKT BIT DEFAULT ((0)),
PAG_PRE MONEY DEFAULT ((0)),
PAG_BAS MONEY DEFAULT ((0)),
PAG_PEC MONEY DEFAULT ((0))
 CONSTRAINT PK_PAGOS PRIMARY KEY CLUSTERED (PAG_NUM,PAG_TIP,PAG_CIA,PAG_ITM),
 CONSTRAINT CK__PAGOS__PAG_CIA__11BF94B6 CHECK ((len([PAG_CIA]) > 0)),
 CONSTRAINT CK__PAGOS__PAG_FOR__149C0161 CHECK ((len([PAG_FOR]) > 0)),
 CONSTRAINT CK__PAGOS__PAG_TIP__0FD74C44 CHECK ((len([PAG_TIP]) > 0)))
CREATE TABLE PAGOSCAJA ( 
CAJ_TIP VARCHAR(3) NOT NULL,
CAJ_NUM INT DEFAULT (0) NOT NULL,
CAJ_CIA CHAR(2) DEFAULT ('01') NOT NULL,
CAJ_FOR VARCHAR(3) NOT NULL,
CAJ_FEC SMALLDATETIME NOT NULL,
CAJ_VAL MONEY DEFAULT (0),
CAJ_CAJ BIT DEFAULT (0) NOT NULL,
CAJ_USU VARCHAR(10)
 CONSTRAINT PK_PAGOSCAJA PRIMARY KEY CLUSTERED (CAJ_TIP,CAJ_NUM,CAJ_CIA,CAJ_FOR),
 CONSTRAINT CK__PAGOSCAJA__CAJ_C__1C3D2329 CHECK ((len([CAJ_CIA]) > 0)),
 CONSTRAINT CK__PAGOSCAJA__CAJ_F__1D314762 CHECK ((len([CAJ_FOR]) > 0)),
 CONSTRAINT CK__PAGOSCAJA__CAJ_T__1960B67E CHECK ((len([CAJ_TIP]) > 0)))
CREATE TABLE PEDCOM ( 
COM_TIP VARCHAR(3) NOT NULL,
COM_NUM INT DEFAULT (0) NOT NULL,
COM_CIA CHAR(2) DEFAULT ('01') NOT NULL,
COM_COM SMALLINT DEFAULT (0) NOT NULL,
COM_COD VARCHAR(16) NOT NULL,
COM_CAN DECIMAL(14,4) DEFAULT (0)
 CONSTRAINT PK_PEDCOM PRIMARY KEY CLUSTERED (COM_TIP,COM_NUM,COM_CIA,COM_COM),
 CONSTRAINT CK__PEDCOM__COM_CIA__24D2692A CHECK ((len([COM_CIA]) > 0)),
 CONSTRAINT CK__PEDCOM__COM_COD__26BAB19C CHECK ((len([COM_COD]) > 0)),
 CONSTRAINT CK__PEDCOM__COM_TIP__21F5FC7F CHECK ((len([COM_TIP]) > 0)))
CREATE TABLE PEDIDOS ( 
PED_NUM INT DEFAULT (0) NOT NULL,
PED_TIP VARCHAR(3) NOT NULL,
PED_CIA CHAR(2) DEFAULT ('01') NOT NULL,
PED_FEC SMALLDATETIME NOT NULL,
PED_CON VARCHAR(3),
PED_CLI VARCHAR(11),
PED_AGE VARCHAR(9) DEFAULT ('N'),
PED_FDE SMALLDATETIME,
PED_VCE SMALLDATETIME,
PED_HOR VARCHAR(15),
PED_VAL MONEY DEFAULT (0),
PED_IVA MONEY DEFAULT (0),
PED_DCT MONEY DEFAULT (0),
PED_FLE MONEY DEFAULT (0),
PED_OTR MONEY DEFAULT (0),
PED_PAG MONEY DEFAULT (0),
PED_IMP MONEY DEFAULT (0),
PED_NET MONEY DEFAULT (0) NOT NULL,
PED_VEN VARCHAR(11),
PED_CDT VARCHAR(11),
PED_SOL VARCHAR(150),
PED_DIR VARCHAR(250),
PED_CIU VARCHAR(8),
PED_LUG VARCHAR(250),
PED_FOR VARCHAR(3),
PED_PES VARCHAR(20),
PED_VOL VARCHAR(15),
PED_TRA VARCHAR(11),
PED_EMP VARCHAR(250),
PED_PLA VARCHAR(10),
PED_APL BIT DEFAULT (0) NOT NULL,
PED_DOC INT DEFAULT (0),
PED_CDC CHAR(2),
PED_REM INT DEFAULT (0),
PED_CRM CHAR(2),
PED_APR INT DEFAULT ((-1)),
PED_CPR CHAR(2) DEFAULT ('01'),
PED_MAY BIT DEFAULT (0) NOT NULL,
PED_SOB BIT DEFAULT (0) NOT NULL,
PED_CAR INT DEFAULT (0),
PED_ORI VARCHAR(8),
PED_IMV MONEY DEFAULT ((0))
 CONSTRAINT PK_PEDIDOS PRIMARY KEY CLUSTERED (PED_NUM,PED_TIP,PED_CIA),
 CONSTRAINT CK__PEDIDOS__PED_CIA__2D67AF2B CHECK ((len([PED_CIA]) > 0)),
 CONSTRAINT CK__PEDIDOS__PED_TIP__2B7F66B9 CHECK ((len([PED_TIP]) > 0)))
CREATE TABLE PEDTANQUES ( 
PTA_TIP VARCHAR(3) NOT NULL,
PTA_NUM INT DEFAULT (0) NOT NULL,
PTA_CIA CHAR(2) DEFAULT ('01') NOT NULL,
PTA_ITM INT DEFAULT (0) NOT NULL,
PTA_COD VARCHAR(16) NOT NULL,
PTA_PRO VARCHAR(16) NOT NULL,
PTA_TAN VARCHAR(3) NOT NULL,
PTA_CAN DECIMAL(10,4) DEFAULT (0) NOT NULL,
PTA_LIN INT DEFAULT (0) NOT NULL
 CONSTRAINT PK_PEDTANQUES PRIMARY KEY CLUSTERED (PTA_TIP,PTA_NUM,PTA_CIA,PTA_ITM),
 CONSTRAINT CK_PEDTANQUESPTA_CIA CHECK ((len([PTA_CIA]) > 0)),
 CONSTRAINT CK_PEDTANQUESPTA_COD CHECK ((len([PTA_COD]) > 0)),
 CONSTRAINT CK_PEDTANQUESPTA_PRO CHECK ((len([PTA_PRO]) > 0)),
 CONSTRAINT CK_PEDTANQUESPTA_TAN CHECK ((len([PTA_TAN]) > 0)),
 CONSTRAINT CK_PEDTANQUESPTA_TIP CHECK ((len([PTA_TIP]) > 0)))
CREATE TABLE PEDTRANS ( 
PED_NUM INT DEFAULT (0) NOT NULL,
PED_TIP VARCHAR(3) DEFAULT ('PDT') NOT NULL,
PED_CIA CHAR(2) DEFAULT ('01') NOT NULL,
PED_FEC SMALLDATETIME,
PED_FDE SMALLDATETIME,
PED_FVC SMALLDATETIME,
PED_REM VARCHAR(11) NOT NULL,
PED_DOR VARCHAR(250),
PED_COR VARCHAR(8) NOT NULL,
PED_DES VARCHAR(11),
PED_DDE VARCHAR(250),
PED_CDE VARCHAR(8) NOT NULL,
PED_VAL MONEY DEFAULT (0),
PED_COS MONEY DEFAULT (0),
PED_PAG MONEY DEFAULT (0),
PED_REF VARCHAR(20),
PED_CON VARCHAR(50),
PED_SIA VARCHAR(50),
PED_SEG VARCHAR(50),
PED_RES VARCHAR(50),
PED_DOC INT DEFAULT (0),
PED_CDC CHAR(2),
PED_ODC INT DEFAULT (0),
PED_COC CHAR(2),
PED_CAR INT DEFAULT (0),
PED_NVH INT DEFAULT (0),
PED_NAT VARCHAR(3),
PED_TVH VARCHAR(3),
PED_VEN VARCHAR(11),
PED_CMS DECIMAL(14,4) DEFAULT (0),
PED_CPC VARCHAR(3),
PED_TEL VARCHAR(30),
PED_NOM VARCHAR(150),
PED_INV INT DEFAULT (0),
PED_CIV CHAR(2),
PED_VIG VARCHAR(10),
PED_APR BIT DEFAULT (0),
PED_DAP VARCHAR(250),
PED_UAP VARCHAR(10),
PED_FAP SMALLDATETIME,
PED_RUT VARCHAR(3)
 CONSTRAINT PK_PEDTRANS PRIMARY KEY CLUSTERED (PED_NUM,PED_TIP,PED_CIA),
 CONSTRAINT CK__PEDTRANS__PED_CD__4727812E CHECK ((len([PED_CDE]) > 0)),
 CONSTRAINT CK__PEDTRANS__PED_CI__444B1483 CHECK ((len([PED_CIA]) > 0)),
 CONSTRAINT CK__PEDTRANS__PED_CO__46335CF5 CHECK ((len([PED_COR]) > 0)),
 CONSTRAINT CK__PEDTRANS__PED_RE__453F38BC CHECK ((len([PED_REM]) > 0)),
 CONSTRAINT CK__PEDTRANS__PED_TI__4262CC11 CHECK ((len([PED_TIP]) > 0)))
CREATE TABLE PLACONTADO ( 
CON_TIP VARCHAR(3) NOT NULL,
CON_NUM INT DEFAULT (0) NOT NULL,
CON_CIA CHAR(2) DEFAULT ('01') NOT NULL,
CON_FEC SMALLDATETIME,
CON_VCB MONEY DEFAULT (0) NOT NULL,
CON_VCI MONEY DEFAULT (0) NOT NULL,
CON_VCD MONEY DEFAULT (0) NOT NULL,
CON_VCC MONEY DEFAULT (0) NOT NULL,
CON_VVB MONEY DEFAULT (0) NOT NULL,
CON_VVI MONEY DEFAULT (0) NOT NULL,
CON_VVD MONEY DEFAULT (0) NOT NULL,
CON_VVC MONEY DEFAULT (0) NOT NULL
 CONSTRAINT PK_PLACONTADO PRIMARY KEY CLUSTERED (CON_TIP,CON_NUM,CON_CIA),
 CONSTRAINT CK_PLACONTADOCON_CIA CHECK ((len([CON_CIA]) > 0)),
 CONSTRAINT CK_PLACONTADOCON_TIP CHECK ((len([CON_TIP]) > 0)))
CREATE TABLE PLAMODFLETE ( 
PLA_TIP VARCHAR(3) DEFAULT ('PLT') NOT NULL,
PLA_NUM INT DEFAULT ((0)) NOT NULL,
PLA_CIA CHAR(2) NOT NULL,
PLA_ITM INT DEFAULT ((0)) NOT NULL,
PLA_FEC SMALLDATETIME NOT NULL,
PLA_VAL MONEY DEFAULT ((0)) NOT NULL,
PLA_RET MONEY DEFAULT ((0)) NOT NULL,
PLA_ICA MONEY DEFAULT ((0)) NOT NULL,
PLA_ANT MONEY DEFAULT ((0)) NOT NULL,
PLA_PES DECIMAL(14,4) DEFAULT ((0)) NOT NULL,
PLA_CUM INT DEFAULT ((0)) NOT NULL,
PLA_RUT VARCHAR(3),
PLA_ORI VARCHAR(8),
PLA_DES VARCHAR(8),
PLA_LUG VARCHAR(8),
PLA_FPA SMALLDATETIME,
PLA_HOR SMALLDATETIME NOT NULL,
PLA_USU VARCHAR(10)
 CONSTRAINT PK_PLAMODFLETE PRIMARY KEY CLUSTERED (PLA_TIP,PLA_NUM,PLA_CIA,PLA_ITM),
 CONSTRAINT CK_PLAMODFLETEPLA_CIA CHECK ((len([PLA_CIA])>(0))),
 CONSTRAINT CK_PLAMODFLETEPLA_TIP CHECK ((len([PLA_TIP])>(0))))
CREATE TABLE PLANILLAS ( 
PLA_NUM INT DEFAULT (0) NOT NULL,
PLA_TIP VARCHAR(3) NOT NULL,
PLA_CIA CHAR(2) DEFAULT ('01') NOT NULL,
PLA_FEC SMALLDATETIME NOT NULL,
PLA_TUR VARCHAR(3),
PLA_CLI VARCHAR(11),
PLA_VAL MONEY DEFAULT (0),
PLA_IVA MONEY DEFAULT (0),
PLA_COS MONEY DEFAULT (0),
PLA_OTR MONEY DEFAULT (0),
PLA_CRE MONEY DEFAULT (0),
PLA_NET MONEY DEFAULT (0) NOT NULL,
PLA_VEN VARCHAR(11),
PLA_CMS DECIMAL(10,4) DEFAULT (0),
PLA_CPC VARCHAR(3),
PLA_NIT VARCHAR(11),
PLA_SOL MONEY DEFAULT (0),
PLA_MOD INT DEFAULT (0) NOT NULL,
PLA_COR INT DEFAULT (0) NOT NULL,
PLA_FCO SMALLDATETIME,
PLA_VCB MONEY DEFAULT (0) NOT NULL,
PLA_VCI MONEY DEFAULT (0) NOT NULL,
PLA_VCD MONEY DEFAULT (0) NOT NULL,
PLA_VCC MONEY DEFAULT (0) NOT NULL,
PLA_VVB MONEY DEFAULT (0) NOT NULL,
PLA_VVI MONEY DEFAULT (0) NOT NULL,
PLA_VVD MONEY DEFAULT (0) NOT NULL,
PLA_VVC MONEY DEFAULT (0) NOT NULL,
PLA_GLO MONEY DEFAULT (0),
PLA_TKT MONEY DEFAULT ((0)),
PLA_EXC MONEY DEFAULT ((0)),
PLA_DCT MONEY DEFAULT ((0))
 CONSTRAINT PK_PLANILLAS PRIMARY KEY CLUSTERED (PLA_NUM,PLA_TIP,PLA_CIA),
 CONSTRAINT CK__PLANILLAS__PLA_C__538D5813 CHECK ((len([PLA_CIA]) > 0)),
 CONSTRAINT CK__PLANILLAS__PLA_T__51A50FA1 CHECK ((len([PLA_TIP]) > 0)))
CREATE TABLE PLATIEMPOS ( 
HOR_TIP VARCHAR(3) NOT NULL,
HOR_NUM INT DEFAULT ((0)) NOT NULL,
HOR_CIA CHAR(2) NOT NULL,
HOR_ITM INT DEFAULT ((0)) NOT NULL,
HOR_TDC VARCHAR(3) NOT NULL,
HOR_DOC INT DEFAULT ((0)) NOT NULL,
HOR_CDC CHAR(2) NOT NULL,
HOR_TEC DECIMAL(14,4) DEFAULT ((0)) NOT NULL,
HOR_TED DECIMAL(14,4) DEFAULT ((0)) NOT NULL,
HOR_FIC SMALLDATETIME,
HOR_FFC SMALLDATETIME,
HOR_FID SMALLDATETIME,
HOR_FFD SMALLDATETIME,
HOR_TRC DECIMAL(14,4) DEFAULT ((0)),
HOR_TRD DECIMAL(14,4) DEFAULT ((0)),
HOR_FLC SMALLDATETIME,
HOR_FSC SMALLDATETIME,
HOR_FLD SMALLDATETIME,
HOR_FSD SMALLDATETIME
 CONSTRAINT PK_PLATIEMPOS PRIMARY KEY CLUSTERED (HOR_TIP,HOR_NUM,HOR_CIA,HOR_ITM),
 CONSTRAINT CK_PLATIEMPOSHOR_CDC CHECK ((len([HOR_CDC])>(0))),
 CONSTRAINT CK_PLATIEMPOSHOR_CIA CHECK ((len([HOR_CIA])>(0))),
 CONSTRAINT CK_PLATIEMPOSHOR_TDC CHECK ((len([HOR_TDC])>(0))),
 CONSTRAINT CK_PLATIEMPOSHOR_TIP CHECK ((len([HOR_TIP])>(0))))
CREATE TABLE PLATRANS ( 
PLA_NUM INT DEFAULT (0) NOT NULL,
PLA_TIP VARCHAR(3) DEFAULT ('PLT') NOT NULL,
PLA_CIA CHAR(2) DEFAULT ('01') NOT NULL,
PLA_FEC SMALLDATETIME,
PLA_RUT VARCHAR(3),
PLA_ORI VARCHAR(8) NOT NULL,
PLA_DES VARCHAR(8) NOT NULL,
PLA_VEH VARCHAR(10) NOT NULL,
PLA_CON VARCHAR(11),
PLA_NIT VARCHAR(11) NOT NULL,
PLA_PAG VARCHAR(8),
PLA_FPA SMALLDATETIME,
PLA_CAR VARCHAR(20),
PLA_DCG VARCHAR(20),
PLA_VAL MONEY DEFAULT (0),
PLA_ANT MONEY DEFAULT (0),
PLA_DCT MONEY DEFAULT (0),
PLA_RET MONEY DEFAULT (0),
PLA_ICA MONEY DEFAULT (0),
PLA_OTR MONEY DEFAULT (0),
PLA_COS MONEY DEFAULT (0),
PLA_NET MONEY DEFAULT (0) NOT NULL,
PLA_ODP INT DEFAULT ((-1)),
PLA_COP CHAR(2),
PLA_LEG INT DEFAULT ((-1)),
PLA_CLE CHAR(2),
PLA_REM INT DEFAULT (0),
PLA_CRM CHAR(2) DEFAULT ('01'),
PLA_FMP BIT DEFAULT (0) NOT NULL,
PLA_TRA VARCHAR(10),
PLA_POL VARCHAR(30),
PLA_FHD SMALLDATETIME,
PLA_FEN SMALLDATETIME,
PLA_KMT INT DEFAULT (0),
PLA_RLF VARCHAR(3),
PLA_VFR MONEY DEFAULT (0),
PLA_NMT VARCHAR(20) DEFAULT ('0'),
PLA_MOD VARCHAR(30) DEFAULT ('GENERAL_INTERURBANO'),
PLA_CTO VARCHAR(8),
PLA_CTD VARCHAR(8),
PLA_KTO INT DEFAULT (0),
PLA_KTD INT DEFAULT (0),
PLA_CSP INT DEFAULT (0),
PLA_MVA VARCHAR(3),
PLA_TRU CHAR(1),
PLA_VFT MONEY DEFAULT ((0)),
PLA_NRA DECIMAL(16,4) DEFAULT ((0)),
PLA_VHC MONEY DEFAULT ((0)),
PLA_VHD MONEY DEFAULT ((0)),
PLA_VAD MONEY DEFAULT ((0)),
PLA_MVL VARCHAR(3),
PLA_VDC MONEY DEFAULT ((0)),
PLA_MVD VARCHAR(3),
PLA_FED SMALLDATETIME,
PLA_NIV INT DEFAULT ((0)),
PLA_CIV CHAR(2),
PLA_INT INT DEFAULT ((0)),
PLA_ERR VARCHAR(1000) DEFAULT (''),
PLA_WSP BIT DEFAULT ((0)),
PLA_MAC VARCHAR(5),
PLA_OAC VARCHAR(250),
PLA_CDR VARCHAR(11),
PLA_NVD INT DEFAULT ((0)),
PLA_NCM INT DEFAULT ((0)),
PLA_CCM CHAR(2),
PLA_TBD INT DEFAULT ((0)) NOT NULL,
PLA_NMR INT DEFAULT ((0)) NOT NULL,
PLA_CMR CHAR(2),
PLA_AFE BIT DEFAULT ((0)) NOT NULL,
PLA_TVP VARCHAR(10) DEFAULT('K')
 CONSTRAINT PK_PLATRANS PRIMARY KEY CLUSTERED (PLA_NUM,PLA_TIP,PLA_CIA),
 CONSTRAINT CK__PLATRANS__PLA_CI__61DB776A CHECK ((len([PLA_CIA]) > 0)),
 CONSTRAINT CK__PLATRANS__PLA_DE__63C3BFDC CHECK ((len([PLA_DES]) > 0)),
 CONSTRAINT CK__PLATRANS__PLA_NI__65AC084E CHECK ((len([PLA_NIT]) > 0)),
 CONSTRAINT CK__PLATRANS__PLA_OR__62CF9BA3 CHECK ((len([PLA_ORI]) > 0)),
 CONSTRAINT CK__PLATRANS__PLA_TI__5FF32EF8 CHECK ((len([PLA_TIP]) > 0)),
 CONSTRAINT CK__PLATRANS__PLA_VE__64B7E415 CHECK ((len([PLA_VEH]) > 0)))
CREATE TABLE PLATURNOS ( 
TUR_NUM INT DEFAULT (0) NOT NULL,
TUR_CIA CHAR(2) DEFAULT ('01') NOT NULL,
TUR_FEC SMALLDATETIME NOT NULL,
TUR_PLA INT DEFAULT (0) NOT NULL,
TUR_FL1 VARCHAR(50),
TUR_FL2 VARCHAR(50),
TUR_USU VARCHAR(10) NOT NULL,
TUR_TIM SMALLDATETIME NOT NULL,
TUR_COR INT DEFAULT ((0)),
TUR_FCO SMALLDATETIME
 CONSTRAINT PK_PLATURNOS PRIMARY KEY CLUSTERED (TUR_NUM,TUR_CIA),
 CONSTRAINT CK_PLATURNOSTUR_CIA CHECK ((len([TUR_CIA]) > 0)),
 CONSTRAINT CK_PLATURNOSTUR_USU CHECK ((len([TUR_USU]) > 0)))
CREATE TABLE RECIBOS ( 
REC_NUM INT DEFAULT (0) NOT NULL,
REC_TIP VARCHAR(3) DEFAULT ('REC') NOT NULL,
REC_CIA CHAR(2) DEFAULT ('01') NOT NULL,
REC_FEC SMALLDATETIME NOT NULL,
REC_CON VARCHAR(3) DEFAULT ('REC') NOT NULL,
REC_CLI VARCHAR(11) NOT NULL,
REC_AGE VARCHAR(9) DEFAULT ('N'),
REC_VAL MONEY DEFAULT (0),
REC_RET MONEY DEFAULT (0),
REC_IVA MONEY DEFAULT (0),
REC_ICA MONEY DEFAULT (0),
REC_MAS MONEY DEFAULT (0),
REC_DCT MONEY DEFAULT (0),
REC_OTR MONEY DEFAULT (0),
REC_NET MONEY DEFAULT (0) NOT NULL,
REC_VEN VARCHAR(11),
REC_CMS DECIMAL(10,4) DEFAULT (0),
REC_CPC VARCHAR(3),
REC_CTA VARCHAR(3),
REC_RTC MONEY DEFAULT ((0)),
REC_TRC DECIMAL(14,4) DEFAULT ((0)),
REC_CRC VARCHAR(3),
REC_REF VARCHAR(50)
 CONSTRAINT PK_RECIBOS PRIMARY KEY CLUSTERED (REC_NUM,REC_TIP,REC_CIA),
 CONSTRAINT CK__RECIBOS__REC_CIA__78BEDCC2 CHECK ((len([REC_CIA]) > 0)),
 CONSTRAINT CK__RECIBOS__REC_CLI__7B9B496D CHECK ((len([REC_CLI]) > 0)),
 CONSTRAINT CK__RECIBOS__REC_CON__7AA72534 CHECK ((len([REC_CON]) > 0)),
 CONSTRAINT CK__RECIBOS__REC_TIP__76D69450 CHECK ((len([REC_TIP]) > 0)))
CREATE TABLE RECPROVISIONAL ( 
RCP_NUM INT DEFAULT (0) NOT NULL,
RCP_CIA CHAR(2) DEFAULT ('01') NOT NULL,
RCP_TIP VARCHAR(3) DEFAULT ('CHE') NOT NULL,
RCP_FEC SMALLDATETIME NOT NULL,
RCP_CLI VARCHAR(11) NOT NULL,
RCP_AGE VARCHAR(9) DEFAULT ('N'),
RCP_VAL MONEY DEFAULT (0)
 CONSTRAINT PK_RECPROVISIONAL PRIMARY KEY CLUSTERED (RCP_NUM,RCP_CIA),
 CONSTRAINT CK__RECPROVIS__RCP_C__09E968C4 CHECK ((len([RCP_CIA]) > 0)),
 CONSTRAINT CK__RECPROVIS__RCP_C__0CC5D56F CHECK ((len([RCP_CLI]) > 0)),
 CONSTRAINT CK__RECPROVIS__RCP_T__0BD1B136 CHECK ((len([RCP_TIP]) > 0)))
CREATE TABLE REMCON ( 
RCO_TIP VARCHAR(3) DEFAULT ('RMT') NOT NULL,
RCO_NUM INT DEFAULT (0) NOT NULL,
RCO_CIA CHAR(2) DEFAULT ('01') NOT NULL,
RCO_NC1 VARCHAR(20) NOT NULL,
RCO_NC2 VARCHAR(20),
RCO_TA1 VARCHAR(10),
RCO_TA2 VARCHAR(10),
RCO_PA1 VARCHAR(15),
RCO_PA2 VARCHAR(15),
RCO_CO1 VARCHAR(20),
RCO_CO2 VARCHAR(20),
RCO_SE1 VARCHAR(250),
RCO_SE2 VARCHAR(250),
RCO_EN1 VARCHAR(20),
RCO_EN2 VARCHAR(20),
RCO_CAR VARCHAR(6)
 CONSTRAINT PK_REMCON PRIMARY KEY CLUSTERED (RCO_TIP,RCO_NUM,RCO_CIA),
 CONSTRAINT CK__REMCON__RCO_CIA__155B1B70 CHECK ((len([RCO_CIA]) > 0)),
 CONSTRAINT CK__REMCON__RCO_NC1__164F3FA9 CHECK ((len([RCO_NC1]) > 0)),
 CONSTRAINT CK__REMCON__RCO_TIP__127EAEC5 CHECK ((len([RCO_TIP]) > 0)))
CREATE TABLE REMESAS ( 
REM_NUM INT DEFAULT (0) NOT NULL,
REM_TIP VARCHAR(3) DEFAULT ('RMT') NOT NULL,
REM_CIA CHAR(2) DEFAULT ('01') NOT NULL,
REM_FEC SMALLDATETIME,
REM_VEH VARCHAR(10) NOT NULL,
REM_CON VARCHAR(11),
REM_REM VARCHAR(11) NOT NULL,
REM_DRM VARCHAR(250),
REM_CRM VARCHAR(8),
REM_DES VARCHAR(11) NOT NULL,
REM_DDE VARCHAR(250),
REM_CDE VARCHAR(8),
REM_LUG VARCHAR(8),
REM_ORD INT DEFAULT (0),
REM_COR CHAR(2),
REM_PLA INT DEFAULT (0),
REM_CPL CHAR(2),
REM_FAC INT DEFAULT ((-1)),
REM_CFA CHAR(2),
REM_PED INT DEFAULT (0),
REM_CPE CHAR(2),
REM_SAL INT DEFAULT (0),
REM_CSA CHAR(2),
REM_VAL MONEY DEFAULT (0),
REM_COS MONEY DEFAULT (0),
REM_TRA VARCHAR(10),
REM_FPA SMALLDATETIME,
REM_DEC MONEY DEFAULT (0),
REM_SEG MONEY DEFAULT (0),
REM_VEN VARCHAR(11),
REM_CMS DECIMAL(14,4) DEFAULT (0),
REM_CPC VARCHAR(3),
REM_TEL VARCHAR(30),
REM_NOM VARCHAR(150),
REM_TOM CHAR(1),
REM_POL VARCHAR(30),
REM_ASE VARCHAR(11),
REM_FVP SMALLDATETIME,
REM_MOD VARCHAR(30) DEFAULT ('GENERAL_INTERURBANO'),
REM_MUD INT DEFAULT (0),
REM_CMU CHAR(2),
REM_NPM VARCHAR(11),
REM_APR BIT DEFAULT ((0)),
REM_DAP VARCHAR(250),
REM_UAP VARCHAR(10),
REM_FAP SMALLDATETIME,
REM_TRU CHAR(1),
REM_PAC BIT DEFAULT ((0)),
REM_HPC INT DEFAULT ((0)),
REM_MPC INT DEFAULT ((0)),
REM_PAD BIT DEFAULT ((0)),
REM_HPD INT DEFAULT ((0)),
REM_MPD INT DEFAULT ((0)),
REM_FCC SMALLDATETIME,
REM_FLC SMALLDATETIME,
REM_FIC SMALLDATETIME,
REM_FFC SMALLDATETIME,
REM_FCD SMALLDATETIME,
REM_FLD SMALLDATETIME,
REM_FID SMALLDATETIME,
REM_FFD SMALLDATETIME,
REM_RCC SMALLDATETIME,
REM_RLC SMALLDATETIME,
REM_RIC SMALLDATETIME,
REM_RFC SMALLDATETIME,
REM_RCD SMALLDATETIME,
REM_RLD SMALLDATETIME,
REM_RID SMALLDATETIME,
REM_RFD SMALLDATETIME,
REM_VIG VARCHAR(10) DEFAULT ('GENERAL'),
REM_RUT VARCHAR(3),
REM_NVD INT DEFAULT ((0)),
REM_NCM INT DEFAULT ((0)),
REM_CCM CHAR(2),
REM_TNF VARCHAR(10)
 CONSTRAINT PK_REMESAS PRIMARY KEY CLUSTERED (REM_NUM,REM_TIP,REM_CIA),
 CONSTRAINT CK__REMESAS__REM_CIA__1CFC3D38 CHECK ((len([REM_CIA]) > 0)),
 CONSTRAINT CK__REMESAS__REM_DES__1FD8A9E3 CHECK ((len([REM_DES]) > 0)),
 CONSTRAINT CK__REMESAS__REM_REM__1EE485AA CHECK ((len([REM_REM]) > 0)),
 CONSTRAINT CK__REMESAS__REM_TIP__1B13F4C6 CHECK ((len([REM_TIP]) > 0)),
 CONSTRAINT CK__REMESAS__REM_VEH__1DF06171 CHECK ((len([REM_VEH]) > 0)))
CREATE TABLE REPORTES ( 
REP_TIP VARCHAR(3) DEFAULT ('PLT') NOT NULL,
REP_NUM INT DEFAULT (0) NOT NULL,
REP_CIA CHAR(2) DEFAULT ('01') NOT NULL,
REP_PUE VARCHAR(3) NOT NULL,
REP_ORD SMALLINT DEFAULT (0),
REP_FEC SMALLDATETIME NOT NULL,
REP_FPR SMALLDATETIME,
REP_HPR SMALLDATETIME,
REP_FRE SMALLDATETIME,
REP_HRE SMALLDATETIME,
REP_REP BIT DEFAULT (0) NOT NULL,
REP_OBS VARCHAR(250),
REP_USU VARCHAR(10)
 CONSTRAINT PK_REPORTES PRIMARY KEY CLUSTERED (REP_TIP,REP_NUM,REP_CIA,REP_PUE),
 CONSTRAINT CK__REPORTES__REP_CI__2F1AED73 CHECK ((len([REP_CIA]) > 0)),
 CONSTRAINT CK__REPORTES__REP_PU__300F11AC CHECK ((len([REP_PUE]) > 0)),
 CONSTRAINT CK__REPORTES__REP_TI__2C3E80C8 CHECK ((len([REP_TIP]) > 0)))
CREATE TABLE SALIDAS ( 
SAL_NUM INT DEFAULT (0) NOT NULL,
SAL_TIP VARCHAR(3) NOT NULL,
SAL_CIA CHAR(2) DEFAULT ('01') NOT NULL,
SAL_FEC SMALLDATETIME NOT NULL,
SAL_CON VARCHAR(3) NOT NULL,
SAL_NIT VARCHAR(11),
SAL_ORD INT DEFAULT (0),
SAL_VAL MONEY DEFAULT (0) NOT NULL,
SAL_IVA MONEY DEFAULT (0),
SAL_ORI VARCHAR(3),
SAL_DES VARCHAR(3),
SAL_REM INT DEFAULT (0),
SAL_CRM CHAR(2),
SAL_CC VARCHAR(3),
SAL_MUD INT DEFAULT (0),
SAL_CMU CHAR(2)
 CONSTRAINT PK_SALIDAS PRIMARY KEY CLUSTERED (SAL_NUM,SAL_TIP,SAL_CIA),
 CONSTRAINT CK__SALIDAS__SAL_CIA__37B03374 CHECK ((len([SAL_CIA]) > 0)),
 CONSTRAINT CK__SALIDAS__SAL_CON__38A457AD CHECK ((len([SAL_CON]) > 0)),
 CONSTRAINT CK__SALIDAS__SAL_TIP__35C7EB02 CHECK ((len([SAL_TIP]) > 0)))
CREATE TABLE SSERVICIO ( 
PED_TIP VARCHAR(3) DEFAULT ('PDT') NOT NULL,
PED_NUM INT DEFAULT (0) NOT NULL,
PED_CIA CHAR(2) DEFAULT ('01') NOT NULL,
PED_FEC SMALLDATETIME NOT NULL,
PED_FCA SMALLDATETIME NOT NULL,
PED_FEN SMALLDATETIME NOT NULL,
PED_ORI VARCHAR(8) NOT NULL,
PED_DES VARCHAR(8) NOT NULL,
PED_CLI VARCHAR(11) NOT NULL,
PED_CGO VARCHAR(30) NOT NULL,
PED_REP VARCHAR(150) NOT NULL,
PED_EML VARCHAR(100),
PED_CLF VARCHAR(11) NOT NULL,
PED_REM VARCHAR(11) NOT NULL,
PED_DRC VARCHAR(250) NOT NULL,
PED_RQC VARCHAR(250),
PED_DTN VARCHAR(11) NOT NULL,
PED_DRD VARCHAR(250) NOT NULL,
PED_RQD VARCHAR(250),
PED_MOD VARCHAR(20) NOT NULL,
PED_CAR VARCHAR(13) NOT NULL,
PED_MER VARCHAR(150) NOT NULL,
PED_DEC MONEY DEFAULT (0) NOT NULL,
PED_ASE VARCHAR(150),
PED_PLE BIT DEFAULT (0) NOT NULL,
PED_PEX BIT DEFAULT (0) NOT NULL,
PED_VPE MONEY DEFAULT (0) NOT NULL,
PED_VPX MONEY DEFAULT (0) NOT NULL,
PED_ESC BIT DEFAULT (0) NOT NULL,
PED_CDC VARCHAR(8),
PED_PAT VARCHAR(50),
PED_SEG VARCHAR(10) NOT NULL,
PED_TVH VARCHAR(3) NOT NULL,
PED_CIC BIT DEFAULT (0) NOT NULL,
PED_CID BIT DEFAULT (0) NOT NULL,
PED_COS MONEY DEFAULT (0) NOT NULL,
PED_OTR MONEY DEFAULT (0) NOT NULL,
PED_VAL MONEY DEFAULT (0) NOT NULL,
PED_CES MONEY DEFAULT (0) NOT NULL,
PED_VEN VARCHAR(11) NOT NULL,
PED_EST VARCHAR(10)
 CONSTRAINT PK_SSERVICIO PRIMARY KEY CLUSTERED (PED_TIP,PED_NUM,PED_CIA),
 CONSTRAINT CK_SSERVICIOPED_CAR CHECK ((len([PED_CAR]) > 0)),
 CONSTRAINT CK_SSERVICIOPED_CGO CHECK ((len([PED_CGO]) > 0)),
 CONSTRAINT CK_SSERVICIOPED_CIA CHECK ((len([PED_CIA]) > 0)),
 CONSTRAINT CK_SSERVICIOPED_CLF CHECK ((len([PED_CLF]) > 0)),
 CONSTRAINT CK_SSERVICIOPED_CLI CHECK ((len([PED_CLI]) > 0)),
 CONSTRAINT CK_SSERVICIOPED_DES CHECK ((len([PED_DES]) > 0)),
 CONSTRAINT CK_SSERVICIOPED_DRC CHECK ((len([PED_DRC]) > 0)),
 CONSTRAINT CK_SSERVICIOPED_DRD CHECK ((len([PED_DRD]) > 0)),
 CONSTRAINT CK_SSERVICIOPED_DTN CHECK ((len([PED_DTN]) > 0)),
 CONSTRAINT CK_SSERVICIOPED_MER CHECK ((len([PED_MER]) > 0)),
 CONSTRAINT CK_SSERVICIOPED_MOD CHECK (([PED_MOD] = 'OTM' or ([PED_MOD] = 'DTA' or ([PED_MOD] = 'EXPORTACION' or [PED_MOD] = 'NACIONALIZADA')))),
 CONSTRAINT CK_SSERVICIOPED_ORI CHECK ((len([PED_ORI]) > 0)),
 CONSTRAINT CK_SSERVICIOPED_REM CHECK ((len([PED_REM]) > 0)),
 CONSTRAINT CK_SSERVICIOPED_REP CHECK ((len([PED_REP]) > 0)),
 CONSTRAINT CK_SSERVICIOPED_SEG CHECK (([PED_SEG] = 'EMPRESA' or [PED_SEG] = 'CLIENTE')),
 CONSTRAINT CK_SSERVICIOPED_TIP CHECK ((len([PED_TIP]) > 0)),
 CONSTRAINT CK_SSERVICIOPED_TVH CHECK ((len([PED_TVH]) > 0)),
 CONSTRAINT CK_SSERVICIOPED_VEN CHECK ((len([PED_VEN]) > 0)))
CREATE TABLE SSESCOLTAS ( 
ESC_TIP VARCHAR(3) DEFAULT ('PDT') NOT NULL,
ESC_NUM INT DEFAULT (0) NOT NULL,
ESC_CIA CHAR(2) DEFAULT ('01') NOT NULL,
ESC_ITM INT DEFAULT (0) NOT NULL,
ESC_COD VARCHAR(3) NOT NULL,
ESC_CAN INT DEFAULT (1) NOT NULL,
ESC_COS MONEY DEFAULT (0) NOT NULL,
ESC_OBS VARCHAR(100)
 CONSTRAINT PK_SSESCOLTAS PRIMARY KEY CLUSTERED (ESC_TIP,ESC_NUM,ESC_CIA,ESC_ITM),
 CONSTRAINT CK_SSESCOLTASESC_CIA CHECK ((len([ESC_CIA]) > 0)),
 CONSTRAINT CK_SSESCOLTASESC_COD CHECK ((len([ESC_COD]) > 0)),
 CONSTRAINT CK_SSESCOLTASESC_TIP CHECK ((len([ESC_TIP]) > 0)))
CREATE TABLE SURUNIDO ( 
SUR_NUE VARCHAR(3) NOT NULL,
SUR_TAN VARCHAR(3) NOT NULL,
SUR_NUM VARCHAR(3) NOT NULL,
SUR_FIN DECIMAL(17,4) DEFAULT (0)
 CONSTRAINT PK_SURUNIDO PRIMARY KEY CLUSTERED (SUR_NUE,SUR_TAN,SUR_NUM),
 CONSTRAINT CK__SURUNIDO__SUR_NU__3F51553C CHECK ((len([SUR_NUE]) > 0)),
 CONSTRAINT CK__SURUNIDO__SUR_NU__41399DAE CHECK ((len([SUR_NUM]) > 0)),
 CONSTRAINT CK__SURUNIDO__SUR_TA__40457975 CHECK ((len([SUR_TAN]) > 0)))
CREATE TABLE Trn_Face ( 
TipDoc VARCHAR(3) NOT NULL,
Documento INT DEFAULT ((0)) NOT NULL,
IdCia CHAR(2) DEFAULT ('01') NOT NULL,
EstadoFE VARCHAR(50) NOT NULL,
Prefijo VARCHAR(20),
NumFace INT DEFAULT ((0)) NOT NULL,
CUFE VARCHAR(500),
CUFE_QR IMAGE,
Resolucion VARCHAR(50),
RangoNum VARCHAR(50),
FecVigencia VARCHAR(50),
Notas VARCHAR(3000),
FechaValidacion DATETIME
 CONSTRAINT PK_Trn_Face PRIMARY KEY CLUSTERED (TipDoc,Documento,IdCia),
 CONSTRAINT CK_Trn_FaceEstadoFE CHECK ((len([EstadoFE])>(0))),
 CONSTRAINT CK_Trn_FaceIdCia CHECK ((len([IdCia])>(0))),
 CONSTRAINT CK_Trn_FaceTipDoc CHECK ((len([TipDoc])>(0))))
CREATE TABLE UNIDOS ( 
UNI_NUE VARCHAR(3) NOT NULL,
UNI_TAN VARCHAR(3) NOT NULL,
UNI_FEC SMALLDATETIME,
UNI_SAL DECIMAL(14,4) DEFAULT (0),
UNI_CAP DECIMAL(14,4) DEFAULT (0),
UNI_USU VARCHAR(10),
UNI_CIA CHAR(2) DEFAULT ('01')
 CONSTRAINT PK_UNIDOS PRIMARY KEY CLUSTERED (UNI_NUE,UNI_TAN),
 CONSTRAINT CK__UNIDOS__UNI_NUE__450A2E92 CHECK ((len([UNI_NUE]) > 0)),
 CONSTRAINT CK__UNIDOS__UNI_TAN__45FE52CB CHECK ((len([UNI_TAN]) > 0)))
CREATE TABLE VALES ( 
VAL_NUM INT DEFAULT (0) NOT NULL,
VAL_TIP VARCHAR(3) DEFAULT ('VAL') NOT NULL,
VAL_CIA CHAR(2) DEFAULT ('01') NOT NULL,
VAL_FEC SMALLDATETIME NOT NULL,
VAL_CON VARCHAR(3) NOT NULL,
VAL_NIT VARCHAR(11),
VAL_DEB MONEY DEFAULT (0),
VAL_CRE MONEY DEFAULT (0)
 CONSTRAINT PK_VALES PRIMARY KEY CLUSTERED (VAL_NUM,VAL_TIP,VAL_CIA),
 CONSTRAINT CK__VALES__VAL_CIA__4F87BD05 CHECK ((len([VAL_CIA]) > 0)),
 CONSTRAINT CK__VALES__VAL_CON__507BE13E CHECK ((len([VAL_CON]) > 0)),
 CONSTRAINT CK__VALES__VAL_TIP__4D9F7493 CHECK ((len([VAL_TIP]) > 0)))
GO
 CREATE NONCLUSTERED INDEX IX_CUMPLIDOSCUM_NDC ON CUMPLIDOS(CUM_TDC,CUM_NDC,CUM_CDC)
 CREATE NONCLUSTERED INDEX IX_CUMPLIDOSCUM_FEC ON CUMPLIDOS(CUM_FEC)

GO
 CREATE NONCLUSTERED INDEX IX_DETCUM_DETNDC ON DETCUM(DET_TDC,DET_NDC,DET_CDC)

GO
 CREATE NONCLUSTERED INDEX IX_DETMOVDET_FEC ON DETMOV(DET_FEC)
 CREATE NONCLUSTERED INDEX IX_DETMOVDET_ORD ON DETMOV(DET_TDC,DET_ORD,DET_COD)

GO
 CREATE NONCLUSTERED INDEX IX_DOCSOPORTESOP_NDR ON DOCSOPORTE(SOP_TDR,SOP_NDR,SOP_CDR)
 CREATE NONCLUSTERED INDEX IX_DOCSOPORTESOP_FEC ON DOCSOPORTE(SOP_FEC)

GO
 CREATE NONCLUSTERED INDEX IX_DOCSOPORTEDETDET_NCO ON DOCSOPORTEDET(DET_TCO,DET_NCO,DET_CCO)

GO
 CREATE NONCLUSTERED INDEX IX_ENTRADASENT_NIT ON ENTRADAS(ENT_NIT)
 CREATE NONCLUSTERED INDEX IX_ENTRADASENT_FEC ON ENTRADAS(ENT_FEC)
 CREATE NONCLUSTERED INDEX IX_ENTRADASENT_CON ON ENTRADAS(ENT_CON)

GO
 CREATE NONCLUSTERED INDEX IX_FACTURASFAC_CLI ON FACTURAS(FAC_CLI)
 CREATE NONCLUSTERED INDEX IX_FACTURASFAC_FEC ON FACTURAS(FAC_FEC)
 CREATE NONCLUSTERED INDEX IX_FACTURASFAC_CON ON FACTURAS(FAC_CON)
 CREATE NONCLUSTERED INDEX IX_FACTURASFAC_NUM ON FACTURAS(FAC_NUM)

GO
 CREATE NONCLUSTERED INDEX IX_KARDEXKAR_COD ON KARDEX(KAR_COD)
 CREATE NONCLUSTERED INDEX IX_KARDEXKAR_FEC ON KARDEX(KAR_FEC)
 CREATE NONCLUSTERED INDEX IX_KARDEXKAR_SEC ON KARDEX(KAR_SEC)
 CREATE NONCLUSTERED INDEX IX_KARDEXKAR_CIA ON KARDEX(KAR_CIA)

GO
 CREATE NONCLUSTERED INDEX IX_MUDANZASMUD_FEC ON MUDANZAS(MUD_FEC)
 CREATE NONCLUSTERED INDEX IX_MUDANZASMUD_CLI ON MUDANZAS(MUD_CLI)

GO
 CREATE NONCLUSTERED INDEX IX_OPAGOODP_FEC ON OPAGO(ODP_FEC)
 CREATE NONCLUSTERED INDEX IX_OPAGOODP_PLA ON OPAGO(ODP_TPL,ODP_PLA,ODP_CPL)
 CREATE NONCLUSTERED INDEX IX_OPAGOODP_VEH ON OPAGO(ODP_VEH)
 CREATE NONCLUSTERED INDEX IX_OPAGOODP_NIT ON OPAGO(ODP_NIT)

GO
 CREATE NONCLUSTERED INDEX IX_PLATURNOSTUR_PLA ON PLATURNOS(TUR_PLA)
 CREATE NONCLUSTERED INDEX IX_PLATURNOSTUR_FEC ON PLATURNOS(TUR_FEC)

GO
