USE [DD_ECM]
GO

/****** Object:  Table [dbo].[TBDEX_OUT]    Script Date: 07.12.2025 13:25:39 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE TABLE [dbo].[TBDEX_OUT](
	[GUID] [bigint] IDENTITY(1,1) NOT NULL,
	[PROFILE_ID] [bigint] NOT NULL,
	[BATCH_ID] [nvarchar](25) NOT NULL,
	[CONTENT] [nvarchar](max) NOT NULL,
	[EXPORT_FILE_NAME] [nvarchar](100) NULL,
	[EXPORT_FILE_HASH_TYPE] [nvarchar](25) NULL,
	[EXPORT_FILE_HASH_VALUE] [nvarchar](250) NULL,
	[EXPORT_WHEN] [datetime] NULL,
	[EXPORT_STATUS] [tinyint] NULL,
	[EXPORT_STATUS_MESSAGE] [nvarchar](max) NULL,
	[COMMENT] [nvarchar](max) NULL,
	[ADDED_WHO] [nvarchar](50) NOT NULL,
	[ADDED_WHEN] [datetime] NOT NULL,
	[CHANGED_WHO] [nvarchar](50) NULL,
	[CHANGED_WHEN] [datetime] NULL,
 CONSTRAINT [PK_TBDEX_OUT] 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] TEXTIMAGE_ON [PRIMARY]
GO

ALTER TABLE [dbo].[TBDEX_OUT] ADD  CONSTRAINT [DF_TBDEX_OUT_ADDED_WHO]  DEFAULT ('DEFAULT') FOR [ADDED_WHO]
GO

ALTER TABLE [dbo].[TBDEX_OUT] ADD  CONSTRAINT [DF_TBDEX_OUT_ADDED_WHEN]  DEFAULT (getdate()) FOR [ADDED_WHEN]
GO

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

ALTER TABLE [dbo].[TBDEX_OUT] CHECK CONSTRAINT [FK_TBDEX_OUT_TBDEX_CONFIG_PROFILE]
GO

CREATE NONCLUSTERED INDEX [IX_TBDEX_OUT_PROFILE_BATCH_ADDED] ON [dbo].[TBDEX_OUT]
(
	[PROFILE_ID] ASC,
	[BATCH_ID] ASC,
	[ADDED_WHEN] DESC
)
WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = ON, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON)
ON [PRIMARY]
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_OUT', @level2type=N'CONSTRAINT',@level2name=N'FK_TBDEX_OUT_TBDEX_CONFIG_PROFILE'
GO


