USE [P543_V2.2]
GO

/****** Object:  Table [dbo].[DIM_buhschet]    Script Date: 09.04.2019 13:05:40 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE TABLE [dbo].[DIM_buhschet](
	[id] [varchar](255) NULL,
	[cnode] [varchar](255) NULL,
	[Код счета БУ] [varchar](255) NULL,
	[Счет БУ] [varchar](255) NULL,
	[schet] [varchar](21) NULL,
	[subsch] [varchar](21) NULL
) ON [PRIMARY]
GO

/****** Object:  Table [dbo].[dim_docs]    Script Date: 09.04.2019 13:05:40 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE TABLE [dbo].[dim_docs](
	[TIDK] [int] NOT NULL,
	[name_doc] [varchar](80) NOT NULL,
	[flag] [int] NOT NULL
) ON [PRIMARY]
GO

/****** Object:  Table [dbo].[dim_documents]    Script Date: 09.04.2019 13:05:40 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE TABLE [dbo].[dim_documents](
	[F$TIDK] [int] NOT NULL,
	[id_DOC] [varchar](255) NULL,
	[docs] [varchar](255) NULL
) ON [PRIMARY]
GO

/****** Object:  Table [dbo].[DIM_IGK]    Script Date: 09.04.2019 13:05:40 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE TABLE [dbo].[DIM_IGK](
	[id] [varchar](255) NULL,
	[Контрагент] [varchar](255) NULL,
	[Госзаказчик] [varchar](255) NULL,
	[ШПЗ] [varchar](255) NULL,
	[NO_DOG] [varchar](100) NULL,
	[MYORG] [varchar](255) NULL,
	[IGK] [varchar](255) NULL,
	[DATE_END] [datetime] NULL,
	[DATE_CUR] [datetime] NULL,
	[DATE_DOG] [datetime] NULL,
	[N_SCHET] [varchar](255) NULL,
	[UNN] [varchar](20) NULL,
	[KODPLATNDS] [varchar](20) NULL,
	[ISMARKED] [int] NULL
) ON [PRIMARY]
GO

/****** Object:  Table [dbo].[dim_katorg]    Script Date: 09.04.2019 13:05:40 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE TABLE [dbo].[dim_katorg](
	[id] [varchar](255) NULL,
	[Контрагент] [varchar](255) NOT NULL
) ON [PRIMARY]
GO

/****** Object:  Table [dbo].[dim_mc]    Script Date: 09.04.2019 13:05:40 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE TABLE [dbo].[dim_mc](
	[id] [varchar](255) NOT NULL,
	[Номенклатура] [varchar](255) NOT NULL,
	[KGROUPMC] [varchar](255) NOT NULL
) ON [PRIMARY]
GO

/****** Object:  Table [dbo].[dim_party]    Script Date: 09.04.2019 13:05:40 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE TABLE [dbo].[dim_party](
	[id] [varchar](20) NULL,
	[Партия] [varchar](255) NOT NULL
) ON [PRIMARY]
GO

/****** Object:  Table [dbo].[dim_shpz]    Script Date: 09.04.2019 13:05:40 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE TABLE [dbo].[dim_shpz](
	[id] [varchar](255) NOT NULL,
	[Контрагент] [varchar](255) NOT NULL,
	[ШПЗ] [varchar](255) NOT NULL,
	[NO_DOG] [varchar](255) NOT NULL,
	[ИГК] [varchar](255) NOT NULL
) ON [PRIMARY]
GO

/****** Object:  Table [dbo].[DIM_ZATR]    Script Date: 09.04.2019 13:05:40 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE TABLE [dbo].[DIM_ZATR](
	[ID] [varchar](255) NULL,
	[Статья затрат] [varchar](255) NULL,
	[Код затрат] [varchar](20) NOT NULL
) ON [PRIMARY]
GO

/****** Object:  Table [dbo].[FACT_OBOROT1C]    Script Date: 09.04.2019 13:05:40 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE TABLE [dbo].[FACT_OBOROT1C](
	[OFICENO] [int] NULL,
	[ID_] [varchar](255) NULL,
	[НомерДокумента] [varchar](255) NULL,
	[TIDK] [int] NULL,
	[id_DOC] [varchar](255) NULL,
	[DATOB] [datetime] NULL,
	[CPLANSSCH] [varchar](255) NULL,
	[F$SCHETO] [varchar](255) NOT NULL,
	[CDEBSS] [varchar](255) NULL,
	[CDEB] [varchar](255) NOT NULL,
	[CSHPZ] [varchar](255) NULL,
	[ШПЗ] [varchar](255) NULL,
	[NO_DOG] [varchar](255) NULL,
	[ORG_NAME] [varchar](255) NULL,
	[CPODR] [varchar](255) NULL,
	[CORG] [varchar](255) NULL,
	[CPARTY] [varchar](255) NULL,
	[CMC] [varchar](255) NULL,
	[CSTZATR] [varchar](255) NULL,
	[CPERSON] [varchar](255) NULL,
	[SUMD1] [float] NULL,
	[SUMD2] [float] NULL,
	[SUMD3] [float] NULL,
	[SUMK4] [float] NULL,
	[SUMK5] [float] NULL,
	[SUMK6] [float] NULL,
	[F$SCHETK] [varchar](255) NOT NULL,
	[CcredsS] [varchar](255) NULL,
	[CCRED] [varchar](255) NOT NULL,
	[CSHPZ_KORR] [varchar](255) NULL,
	[ШПЗ_КОР] [varchar](255) NULL,
	[NO_DOG_KORR] [varchar](255) NULL,
	[ORG_NAME_KORR] [varchar](255) NULL,
	[CORG_CORR] [varchar](255) NULL,
	[CPARTY_CORR] [varchar](255) NULL,
	[CMC_CORR] [varchar](255) NULL,
	[CSTZATR_CORR] [varchar](255) NULL,
	[CPERSON_CORR] [varchar](255) NULL,
	[SUMD] [float] NULL,
	[SUMK] [float] NULL,
	[isDeb] [int] NULL,
	[sum0] [float] NULL,
	[line] [int] NULL,
	[line_txt] [varchar](255) NULL,
	[sum3] [float] NULL
) ON [PRIMARY]
GO

/****** Object:  Table [dbo].[FACT_OBOROT2]    Script Date: 09.04.2019 13:05:40 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE TABLE [dbo].[FACT_OBOROT2](
	[OFICENO] [int] NULL,
	[ID_] [varchar](255) NULL,
	[НомерДокумента] [varchar](255) NULL,
	[TIDK] [int] NULL,
	[id_DOC] [varchar](255) NULL,
	[DATOB] [datetime] NULL,
	[CPLANSSCH] [varchar](255) NULL,
	[F$SCHETO] [varchar](255) NOT NULL,
	[CDEBSS] [varchar](255) NULL,
	[CDEB] [varchar](255) NOT NULL,
	[CSHPZ] [varchar](255) NULL,
	[ШПЗ] [varchar](255) NULL,
	[NO_DOG] [varchar](255) NULL,
	[ORG_NAME] [varchar](255) NULL,
	[CPODR] [varchar](255) NULL,
	[CORG] [varchar](255) NULL,
	[CPARTY] [varchar](255) NULL,
	[CMC] [varchar](255) NULL,
	[CSTZATR] [varchar](255) NULL,
	[CPERSON] [varchar](255) NULL,
	[SUMD1] [float] NULL,
	[SUMD2] [float] NULL,
	[SUMD3] [float] NULL,
	[SUMK4] [float] NULL,
	[SUMK5] [float] NULL,
	[SUMK6] [float] NULL,
	[F$SCHETK] [varchar](255) NOT NULL,
	[CcredsS] [varchar](255) NULL,
	[CCRED] [varchar](255) NOT NULL,
	[CSHPZ_KORR] [varchar](255) NULL,
	[ШПЗ_КОР] [varchar](255) NULL,
	[NO_DOG_KORR] [varchar](255) NULL,
	[ORG_NAME_KORR] [varchar](255) NULL,
	[CORG_CORR] [varchar](255) NULL,
	[CPARTY_CORR] [varchar](255) NULL,
	[CMC_CORR] [varchar](255) NULL,
	[CSTZATR_CORR] [varchar](255) NULL,
	[CPERSON_CORR] [varchar](255) NULL,
	[SUMD] [float] NULL,
	[SUMK] [float] NULL,
	[isDeb] [int] NULL,
	[sum0] [float] NULL,
	[line] [int] NULL,
	[line_txt] [varchar](255) NULL,
	[sum3] [float] NULL
) ON [PRIMARY]
GO

/****** Object:  Table [dbo].[rep_shbl]    Script Date: 09.04.2019 13:05:40 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE TABLE [dbo].[rep_shbl](
	[no_str] [varchar](20) NOT NULL,
	[str_name] [nvarchar](max) NOT NULL,
	[shet_deb] [varchar](20) NULL,
	[shet_cred] [varchar](20) NULL,
	[id] [int] NOT NULL
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO

/****** Object:  Table [dbo].[Tab1_param_contr_1с]    Script Date: 09.04.2019 13:05:40 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE TABLE [dbo].[Tab1_param_contr_1с](
	[ВиДоговора] [nvarchar](255) NULL,
	[НомерКонтракта] [nvarchar](255) NULL,
	[ДатаКонтракта] [datetime] NULL,
	[ИГК] [nvarchar](255) NULL,
	[Госзаказчик] [nvarchar](255) NULL,
	[Контрагент] [nvarchar](255) NULL,
	[ПлановаяДатаисполненияКонтракта] [datetime] NULL,
	[Номервыделенногосчета] [nvarchar](255) NULL,
	[Sum_IGK] [decimal](28, 10) NULL,
	[Sum1] [decimal](28, 10) NULL,
	[Sum2] [decimal](28, 10) NULL,
	[Sum3] [decimal](28, 10) NULL,
	[Sum4] [decimal](28, 10) NULL,
	[Sum5] [decimal](28, 10) NULL,
	[Sum6] [decimal](28, 10) NULL,
	[Sum7] [decimal](28, 10) NULL,
	[Sum8] [decimal](28, 10) NULL,
	[Sum9] [decimal](28, 10) NULL,
	[Sum10] [decimal](28, 10) NULL,
	[Sum11] [decimal](28, 10) NULL,
	[Sum12] [decimal](28, 10) NULL
) ON [PRIMARY]
GO

/****** Object:  Table [dbo].[Tab2_reestr_dogovor_1с]    Script Date: 09.04.2019 13:05:40 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE TABLE [dbo].[Tab2_reestr_dogovor_1с](
	[Идентификатор] [nvarchar](255) NULL,
	[НомерДатаДоговора] [nvarchar](255) NULL,
	[ВидДоговора] [nvarchar](255) NULL
) ON [PRIMARY]
GO

/****** Object:  Table [dbo].[Tab3_reestr_shpz_1C]    Script Date: 09.04.2019 13:05:40 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE TABLE [dbo].[Tab3_reestr_shpz_1C](
	[КодВидаНоменклатуры] [nvarchar](255) NULL,
	[ВидДоговора] [nvarchar](255) NULL
) ON [PRIMARY]
GO

/****** Object:  Table [dbo].[Tab4_plan_1c]    Script Date: 09.04.2019 13:05:40 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE TABLE [dbo].[Tab4_plan_1c](
	[Код] [nvarchar](255) NULL,
	[Наименование] [nvarchar](255) NULL,
	[Субконто_x0020_1] [nvarchar](255) NULL,
	[Субконто_x0020_2] [nvarchar](255) NULL,
	[Субконто_x0020_3] [nvarchar](255) NULL,
	[ИдентификацияИГК] [nvarchar](255) NULL,
	[ИдентификацияШПЗ] [nvarchar](255) NULL,
	[ИдентификацияСтЗатр] [nvarchar](255) NULL,
	[ИдентификацияНоменкл] [nvarchar](255) NULL,
	[ИдентификацияПарт] [nvarchar](255) NULL,
	[СчетСервиса] [nvarchar](255) NULL,
	[КАУ1] [nvarchar](255) NULL,
	[КАУ2] [nvarchar](255) NULL,
	[КАУ3] [nvarchar](255) NULL,
	[ИдентификацияКонтрагент] [nvarchar](255) NULL
) ON [PRIMARY]
GO

/****** Object:  Table [dbo].[Tab5_oper_1c]    Script Date: 09.04.2019 13:05:40 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE TABLE [dbo].[Tab5_oper_1c](
	[id_obor] [nvarchar](255) NULL,
	[id_doc] [nvarchar](255) NULL,
	[Дата] [datetime] NULL,
	[Документ] [nvarchar](255) NULL,
	[Счет_x0020_Дт] [nvarchar](255) NULL,
	[Субконто1_x0020_Дт] [nvarchar](255) NULL,
	[Субконто2_x0020_Дт] [nvarchar](255) NULL,
	[Субконто3_x0020_Дт] [nvarchar](255) NULL,
	[Счет_x0020_Кт] [nvarchar](255) NULL,
	[Субконто1_x0020_Кт] [nvarchar](255) NULL,
	[Субконто2_x0020_Кт] [nvarchar](255) NULL,
	[Субконто3_x0020_Кт] [nvarchar](255) NULL,
	[Сумма] [decimal](28, 10) NULL,
	[Содержание] [nvarchar](255) NULL,
	[KAU1D] [nvarchar](255) NULL,
	[KAU2D] [nvarchar](255) NULL,
	[KAU3D] [nvarchar](255) NULL,
	[KAU1K] [nvarchar](255) NULL,
	[KAU2K] [nvarchar](255) NULL,
	[KAU3K] [nvarchar](255) NULL
) ON [PRIMARY]
GO

/****** Object:  Table [dbo].[Tab5_temp]    Script Date: 09.04.2019 13:05:40 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE TABLE [dbo].[Tab5_temp](
	[id_obor] [nvarchar](255) NULL,
	[id_doc] [nvarchar](255) NULL,
	[Дата] [date] NULL,
	[Документ] [nvarchar](255) NULL,
	[СчетДт] [nvarchar](255) NULL,
	[Субконто1Дт] [nvarchar](255) NULL,
	[Субконто2Дт] [nvarchar](255) NULL,
	[Субконто3Дт] [nvarchar](255) NULL,
	[СчетКт] [nvarchar](255) NULL,
	[Субконто1Кт] [nvarchar](255) NULL,
	[Субконто2Кт] [nvarchar](255) NULL,
	[Субконто3Кт] [nvarchar](255) NULL,
	[Сумма] [decimal](24, 5) NULL,
	[Содержание] [nvarchar](255) NULL,
	[KAU1D] [varchar](255) NULL,
	[KAU1K] [varchar](255) NULL,
	[KAU2D] [varchar](255) NULL,
	[KAU2K] [varchar](255) NULL,
	[KAU3D] [varchar](255) NULL,
	[KAU3K] [varchar](255) NULL
) ON [PRIMARY]
GO

/****** Object:  Table [dbo].[Tab6_zatraty_20_1c]    Script Date: 09.04.2019 13:05:40 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE TABLE [dbo].[Tab6_zatraty_20_1c](
	[Код] [nvarchar](255) NULL,
	[Наименование] [nvarchar](255) NULL,
	[ГрафаОтчета] [nvarchar](255) NULL,
	[НаименованиеПоказателя] [nvarchar](255) NULL
) ON [PRIMARY]
GO

/****** Object:  Table [dbo].[tab7_schet_1c]    Script Date: 09.04.2019 13:05:40 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE TABLE [dbo].[tab7_schet_1c](
	[РасчетныйСчетИд] [nvarchar](255) NULL,
	[РасчетныйСчет] [nvarchar](255) NULL
) ON [PRIMARY]
GO

/****** Object:  Table [dbo].[tQData]    Script Date: 09.04.2019 13:05:40 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE TABLE [dbo].[tQData](
	[IGK] [varchar](255) NULL,
	[NRow] [varchar](100) NULL,
	[doVal_1] [float] NULL,
	[doVal_2] [float] NULL,
	[doVal_3] [float] NULL,
	[doVal_4] [float] NULL,
	[doVal_5] [float] NULL,
	[doVal_6] [float] NULL,
	[doVal_7] [float] NULL,
	[doVal_8] [float] NULL,
	[doVal_9] [float] NULL,
	[dOtch] [date] NULL
) ON [PRIMARY]
GO

/****** Object:  Table [dbo].[XMLwithOpenXML]    Script Date: 09.04.2019 13:05:40 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE TABLE [dbo].[XMLwithOpenXML](
	[Id] [int] IDENTITY(1,1) NOT NULL,
	[XMLData] [xml] NULL,
	[LoadedDateTime] [datetime] NULL,
PRIMARY KEY CLUSTERED 
(
	[Id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO

/****** Object:  Table [dbo].[Время]    Script Date: 09.04.2019 13:05:40 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE TABLE [dbo].[Время](
	[PK_Дата] [datetime] NOT NULL,
	[Дата_Имя] [nvarchar](50) NULL,
	[Год] [datetime] NULL,
	[Год_Имя] [nvarchar](50) NULL,
	[Квартал] [datetime] NULL,
	[Квартал_Имя] [nvarchar](50) NULL,
	[Месяц] [datetime] NULL,
	[Месяц_Имя] [nvarchar](50) NULL,
	[День_Года] [int] NULL,
	[День_Года_Имя] [nvarchar](50) NULL,
	[День_Квартала] [int] NULL,
	[День_Квартала_Имя] [nvarchar](50) NULL,
	[День_Месяца] [int] NULL,
	[День_Месяца_Имя] [nvarchar](50) NULL,
	[Месяц_Года] [int] NULL,
	[Месяц_Года_Имя] [nvarchar](50) NULL,
	[Месяц_Квартала] [int] NULL,
	[Месяц_Квартала_Имя] [nvarchar](50) NULL,
	[Квартал_Года] [int] NULL,
	[Квартал_Года_Имя] [nvarchar](50) NULL,
	[flag] [int] NULL
) ON [PRIMARY]
GO

ALTER TABLE [dbo].[DIM_IGK] ADD  DEFAULT ((0)) FOR [ISMARKED]
GO

