USE [DD_ECM]
GO

/****** Object:  Table [dbo].[TBDEX_CFG_OUT_STRUCTURE]    Script Date: 07.12.2025 23:14:25 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE TABLE [dbo].[TBDEX_CFG_OUT_STRUCTURE](
	[GUID] [bigint] IDENTITY(1,1) NOT NULL,
	[PROFILE_ID] [bigint] NOT NULL,
	[ACTIVE] [bit] NOT NULL,
	[DESCRIPTION] [nvarchar](500) NULL,
	[EXPORT_TYPE] [nvarchar](50) NOT NULL,
	[SEQUENCE] [tinyint] NOT NULL,
	[PATH_OR_COLUMN] [nvarchar](500) NOT NULL,
	[DATA_TYPE] [nvarchar](50) NOT NULL,
	[LANGUAGE] [nvarchar](10) NOT NULL,
	[COMMENT] [nvarchar](250) NULL,
	[ADDED_WHO] [nvarchar](50) NOT NULL,
	[ADDED_WHEN] [datetime] NOT NULL,
	[CHANGED_WHO] [nvarchar](50) NULL,
	[CHANGED_WHEN] [datetime] NULL,
 CONSTRAINT [PK_TBDEX_CFG_OUT_STRUCTURE] PRIMARY KEY CLUSTERED 
(
	[GUID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = ON, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, FILLFACTOR = 80, OPTIMIZE_FOR_SEQUENTIAL_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
GO

ALTER TABLE [dbo].[TBDEX_CFG_OUT_STRUCTURE] ADD  CONSTRAINT [DF_TBDEX_CFG_OUT_STRUCTURE_ACTIVE]  DEFAULT ((0)) FOR [ACTIVE]
GO

ALTER TABLE [dbo].[TBDEX_CFG_OUT_STRUCTURE] ADD  CONSTRAINT [DF_TBDEX_CFG_OUT_STRUCTURE_LEVEL_OR_COLUMN_NUMBER]  DEFAULT ((0)) FOR [SEQUENCE]
GO

ALTER TABLE [dbo].[TBDEX_CFG_OUT_STRUCTURE] ADD  CONSTRAINT [DF_TBDEX_CFG_OUT_STRUCTURE_DATA_TYPE]  DEFAULT ('NVARCHAR(100)') FOR [DATA_TYPE]
GO

ALTER TABLE [dbo].[TBDEX_CFG_OUT_STRUCTURE] ADD  CONSTRAINT [DF_TBDEX_CFG_OUT_STRUCTURE_LANGUAGE]  DEFAULT ('de_DE') FOR [LANGUAGE]
GO

ALTER TABLE [dbo].[TBDEX_CFG_OUT_STRUCTURE] ADD  CONSTRAINT [DF_TBDEX_CFG_OUT_STRUCTURE_ADDED_WHO]  DEFAULT ('DEFAULT') FOR [ADDED_WHO]
GO

ALTER TABLE [dbo].[TBDEX_CFG_OUT_STRUCTURE] ADD  CONSTRAINT [DF_TBDEX_CFG_OUT_STRUCTURE_ADDED_WHEN]  DEFAULT (getdate()) FOR [ADDED_WHEN]
GO

ALTER TABLE [dbo].[TBDEX_CFG_OUT_STRUCTURE]  WITH CHECK ADD  CONSTRAINT [FK_TBDEX_CFG_OUT_STRUCTURE_TBDEX_CFG_PROFILE] FOREIGN KEY([PROFILE_ID])
REFERENCES [dbo].[TBDEX_CFG_PROFILE] ([GUID])
GO

ALTER TABLE [dbo].[TBDEX_CFG_OUT_STRUCTURE] CHECK CONSTRAINT [FK_TBDEX_CFG_OUT_STRUCTURE_TBDEX_CFG_PROFILE]
GO

ALTER TABLE [dbo].[TBDEX_CFG_OUT_STRUCTURE]  WITH CHECK ADD  CONSTRAINT [CK_TBDEX_CFG_OUT_STRUCTURE_EXPORT_TYPE] CHECK  ((upper([DATA_TYPE])='DATETIME2' OR upper([DATA_TYPE])='DATETIME' OR upper([DATA_TYPE])='DATE' OR upper([DATA_TYPE])='FLOAT' OR upper([DATA_TYPE])='BIGINT' OR upper([DATA_TYPE])='INT' OR upper([DATA_TYPE])='TINYINT' OR upper([DATA_TYPE]) like '%VARCHAR%'))
GO

ALTER TABLE [dbo].[TBDEX_CFG_OUT_STRUCTURE] CHECK CONSTRAINT [CK_TBDEX_CFG_OUT_STRUCTURE_EXPORT_TYPE]
GO

EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'Link PROFILE_ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'TBDEX_CFG_OUT_STRUCTURE', @level2type=N'CONSTRAINT',@level2name=N'FK_TBDEX_CFG_OUT_STRUCTURE_TBDEX_CFG_PROFILE'
GO


