CREATE TABLE TMPESF ( 
TMP_CUE VARCHAR(16) NOT NULL,
TMP_CIA CHAR(2) DEFAULT ('00') NOT NULL,
TMP_ID INT DEFAULT ((0)) NOT NULL,
TMP_UID CHAR(2) DEFAULT ('01') NOT NULL,
TMP_SAN MONEY DEFAULT ((0)),
TMP_DEB MONEY DEFAULT ((0)),
TMP_CRE MONEY DEFAULT ((0)),
TMP_SAL MONEY DEFAULT ((0)),
TMP_SA2 MONEY DEFAULT ((0)),
TMP_DB2 MONEY DEFAULT ((0)),
TMP_CR2 MONEY DEFAULT ((0)),
TMP_NS2 MONEY DEFAULT ((0)),
TMP_NOS BIT DEFAULT ((0)) NOT NULL
 CONSTRAINT PK_TMPESF PRIMARY KEY CLUSTERED (TMP_CUE,TMP_CIA,TMP_ID,TMP_UID),
 CONSTRAINT CK_TMPESFTMP_CIA CHECK ((len([TMP_CIA])>(0))),
 CONSTRAINT CK_TMPESFTMP_CUE CHECK ((len([TMP_CUE])>(0))),
 CONSTRAINT CK_TMPESFTMP_UID CHECK ((len([TMP_UID])>(0))))
GO
CREATE TABLE TMPLBCN ( 
TMP_CUE VARCHAR(16) NOT NULL,
TMP_CIA CHAR(2) DEFAULT ('00') NOT NULL,
TMP_NIT VARCHAR(11) DEFAULT ('000') NOT NULL,
TMP_CC VARCHAR(3) DEFAULT ('000') NOT NULL,
TMP_ID INT DEFAULT ((0)) NOT NULL,
TMP_UID CHAR(2) DEFAULT ('01') NOT NULL,
TMP_AGE VARCHAR(9) DEFAULT ('N'),
TMP_DES VARCHAR(50),
TMP_NOS BIT DEFAULT ((0)) NOT NULL,
TMP_SAN MONEY DEFAULT ((0)),
TMP_DEB MONEY DEFAULT ((0)),
TMP_CRE MONEY DEFAULT ((0)),
TMP_SAL MONEY DEFAULT ((0)),
TMP_SA2 MONEY DEFAULT ((0)),
TMP_DB2 MONEY DEFAULT ((0)),
TMP_CR2 MONEY DEFAULT ((0)),
TMP_NS2 MONEY DEFAULT ((0))
 CONSTRAINT PK_TMPLBCN PRIMARY KEY CLUSTERED (TMP_CUE,TMP_CIA,TMP_NIT,TMP_CC,TMP_ID,TMP_UID),
 CONSTRAINT CK_TMPLBCNTMP_CC CHECK ((len([TMP_CC])>(0))),
 CONSTRAINT CK_TMPLBCNTMP_CIA CHECK ((len([TMP_CIA])>(0))),
 CONSTRAINT CK_TMPLBCNTMP_CUE CHECK ((len([TMP_CUE])>(0))),
 CONSTRAINT CK_TMPLBCNTMP_NIT CHECK ((len([TMP_NIT])>(0))),
 CONSTRAINT CK_TMPLBCNTMP_UID CHECK ((len([TMP_UID])>(0))))
GO
CREATE TABLE TMPLMNIIF ( 
TMP_TIP VARCHAR(3) NOT NULL,
TMP_NUM INT DEFAULT ((0)) NOT NULL,
TMP_CIA CHAR(2) DEFAULT ('01') NOT NULL,
TMP_ITM INT DEFAULT ((0)) NOT NULL,
TMP_UID CHAR(2) DEFAULT ('01') NOT NULL,
TMP_FEC SMALLDATETIME,
TMP_ORD INT DEFAULT ((0)),
TMP_CUE VARCHAR(16) NOT NULL,
TMP_NIT VARCHAR(11),
TMP_CTA VARCHAR(3),
TMP_CC VARCHAR(3),
TMP_DEB MONEY DEFAULT ((0)),
TMP_CRE MONEY DEFAULT ((0)),
TMP_SCU MONEY DEFAULT ((0)),
TMP_SCI MONEY DEFAULT ((0)),
TMP_SNI MONEY DEFAULT ((0)),
TMP_SCO MONEY DEFAULT ((0)),
TMP_SBA MONEY DEFAULT ((0)),
TMP_SCN MONEY DEFAULT ((0)),
TMP_SCC MONEY DEFAULT ((0)),
TMP_SCB MONEY DEFAULT ((0)),
TMP_CCC MONEY DEFAULT ((0)),
TMP_CNC MONEY DEFAULT ((0)),
TMP_SAN MONEY DEFAULT ((0)),
TMP_SAL MONEY DEFAULT ((0)),
TMP_DET VARCHAR(250),
TMP_CON VARCHAR(3),
TMP_BAS MONEY DEFAULT ((0)),
TMP_TDC VARCHAR(3),
TMP_DOC INT DEFAULT ((0)),
TMP_CDC CHAR(2) DEFAULT ('01'),
TMP_TFA VARCHAR(3),
TMP_FAC VARCHAR(10),
TMP_NV DECIMAL(14,4) DEFAULT ((0)),
TMP_CFA CHAR(2) DEFAULT ('01'),
TMP_FVC SMALLDATETIME,
TMP_CHE VARCHAR(20),
TMP_INT BIT DEFAULT ((0)) NOT NULL,
TMP_VEN CHAR(1) DEFAULT ('N'),
TMP_AGE VARCHAR(9) DEFAULT ('N'),
TMP_USU VARCHAR(10)
 CONSTRAINT PK_TMPLMNIIF PRIMARY KEY CLUSTERED (TMP_TIP,TMP_NUM,TMP_CIA,TMP_ITM,TMP_UID),
 CONSTRAINT CK_TMPLMNIIFTMP_CIA CHECK ((len([TMP_CIA])>(0))),
 CONSTRAINT CK_TMPLMNIIFTMP_CUE CHECK ((len([TMP_CUE])>(0))),
 CONSTRAINT CK_TMPLMNIIFTMP_TIP CHECK ((len([TMP_TIP])>(0))),
 CONSTRAINT CK_TMPLMNIIFTMP_UID CHECK ((len([TMP_UID])>(0))))
GO