CREATE TABLE [import].[ACCT_DOC_KEY] (
   [UNIQUE_IDENT] [numeric](12,0) NOT NULL,
   [ACCT_NO] [char](10) NOT NULL,
   [BOOKKEEP_DATE] [datetime] NOT NULL,
   [BOOKKEEP_PERIOD] [numeric](6,0) NOT NULL,
   [DOCUMENT_NO] [numeric](15,0) NOT NULL,
   [BATCH_NO] [numeric](15,0) NOT NULL,
   [JOURNAL_NO] [numeric](15,0) NOT NULL,
   [BOOK_NO] [char](3) NOT NULL,
   [ORIGIN] [char](1) NOT NULL,
   [STATUS] [char](1) NOT NULL,
   [DEBIT_AMOUNT] [numeric](15,2) NOT NULL,
   [CREDIT_AMOUNT] [numeric](15,2) NOT NULL,
   [DEBIT_QUANTITY] [numeric](15,3) NOT NULL,
   [CREDIT_QUANTITY] [numeric](15,3) NOT NULL,
   [AA_TRTYPE] [numeric](4,0) NOT NULL,
   [SITE] [char](10) NOT NULL,
   [STRATEGIC_AREA] [char](10) NOT NULL,
   [DEPARTMENT] [char](4) NOT NULL,
   [ACTIVITY] [char](2) NOT NULL,
   [STOCK] [char](2) NOT NULL,
   [MAKE_FAMILY] [char](2) NOT NULL,
   [MAKE] [char](2) NOT NULL,
   [VEHICLE_TYPE] [char](1) NOT NULL,
   [MODEL_LINE] [char](2) NOT NULL,
   [FACTORY_MODEL] [varchar](20) NOT NULL,
   [WORKSHOP_MODEL] [char](6) NOT NULL,
   [PRODUCT_GROUP] [char](3) NOT NULL,
   [REPAIR_GROUP] [char](3) NOT NULL,
   [KIT_GROUP] [char](2) NOT NULL,
   [VAT_CODE_ORDER] [char](1) NOT NULL,
   [TIME_CODE] [char](2) NOT NULL,
   [INT_EXT_CODE] [char](1) NOT NULL,
   [DESTINATION] [char](2) NOT NULL,
   [PRICE_CODE] [char](2) NOT NULL,
   [REDUCTION_CODE] [char](2) NOT NULL,
   [VAT_RATE_CODE] [char](2) NOT NULL,
   [MISC_NO] [varchar](22) NOT NULL,
   [BOOKKEEPING_CODE] [char](10) NOT NULL,
   [COST_REVENUE_CODE] [char](1) NOT NULL,
   [REASON_CODE] [char](2) NOT NULL,
   [PART_GROUP] [char](10) NOT NULL,
   [OWN_DIMENSION_1] [varchar](30) NOT NULL,
   [OWN_DIMENSION_2] [varchar](30) NOT NULL,
   [OWN_DIMENSION_3] [varchar](30) NOT NULL,
   [OWN_DIMENSION_4] [varchar](30) NOT NULL,
   [OWN_DIMENSION_5] [varchar](30) NOT NULL,
   [INT_VOUCHER_NO] [numeric](15,0) NULL,
   [BALANCING_MARK] [char](1) NULL,
   [ACCT_SCHEDULE_ID] [char](10) NULL,
   [REGISTER_NUMBER] [char](10) NULL,
   [PURCH_ORIGIN_CODE] [char](2) NULL,
   [USED_VEH_DEST_CODE] [char](1) NULL,
   [USE_OF_VEHICLE] [char](2) NULL,
   [ACCT_NO_NEXT_CHART] [char](10) NOT NULL,
   [DEPARTMENT_NEXT_CHART] [char](4) NOT NULL,
   [CONV_FLAG] [char](1) NULL,
   [timestamp] [binary](8) NOT NULL,
   [CL_DET_CODE] [char](1) NULL,
   [CL_TROUBLE_CODE] [char](3) NULL,
   [CL_TYPE] [char](3) NULL,
   [PURCH_SALESMAN] [char](4) NULL,
   [SALE_SALESMAN] [char](4) NULL,
   [CLIENT_DB] [varchar](20) NOT NULL

   ,CONSTRAINT [PK_ACCT_DOC_KEYUNIQUE_IDENT] PRIMARY KEY CLUSTERED ([UNIQUE_IDENT], [CLIENT_DB])
)

CREATE NONCLUSTERED INDEX [ACCT_DOC_KEY$1] ON [import].[ACCT_DOC_KEY] ([ACCT_NO], [BOOKKEEP_DATE]) INCLUDE ([BOOKKEEP_PERIOD], [DOCUMENT_NO], [ORIGIN], [STATUS], [DEBIT_AMOUNT], [CREDIT_AMOUNT], [DEBIT_QUANTITY], [CREDIT_QUANTITY], [AA_TRTYPE], [DEPARTMENT], [STOCK], [MAKE_FAMILY], [MAKE], [VEHICLE_TYPE], [MODEL_LINE], [FACTORY_MODEL], [WORKSHOP_MODEL], [PRODUCT_GROUP], [REPAIR_GROUP], [KIT_GROUP], [TIME_CODE], [INT_VOUCHER_NO], [BALANCING_MARK], [USED_VEH_DEST_CODE], [USE_OF_VEHICLE], [ACCT_NO_NEXT_CHART])
CREATE NONCLUSTERED INDEX [IX_ACCT_DOC_KEY] ON [import].[ACCT_DOC_KEY] ([ACCT_NO], [CLIENT_DB])
CREATE NONCLUSTERED INDEX [IX_ACCT_DOC_KEY_1] ON [import].[ACCT_DOC_KEY] ([DEPARTMENT], [CLIENT_DB])
CREATE NONCLUSTERED INDEX [IX_ACCT_DOC_KEY_2] ON [import].[ACCT_DOC_KEY] ([AA_TRTYPE], [CLIENT_DB])
CREATE NONCLUSTERED INDEX [IX_ACCT_DOC_KEY_3] ON [import].[ACCT_DOC_KEY] ([BOOKKEEP_DATE])

GO
