USE [DD_ECM]
GO

/****** Object:  Table [dbo].[TBDEX_RUN_NUMBER_RANGE]    Script Date: 07.12.2025 23:26:21 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE TABLE [dbo].[TBDEX_RUN_NUMBER_RANGE](
	[GUID] [bigint] IDENTITY(1,1) NOT NULL,
	[PROFILE_ID] [bigint] NOT NULL,
	[ACTIVE] [bit] NOT NULL,
	[DESCRIPTION] [nvarchar](50) NULL,
	[EXPORT_NUMBER_SCHEMA] [nvarchar](25) NOT NULL,
	[EXPORT_NUMBER_COUNTER] [bigint] NOT NULL,
	[EXPORT_NUMBER] [nvarchar](25) NOT NULL,
	[VALID_FROM] [date] NULL,
	[VALID_TO] [date] 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_RUN_NUMBER_RANGE] 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_RUN_NUMBER_RANGE] ADD  CONSTRAINT [DF_TBDEX_RUN_NUMBER_RANGE_ACTIVE]  DEFAULT ((0)) FOR [ACTIVE]
GO

ALTER TABLE [dbo].[TBDEX_RUN_NUMBER_RANGE] ADD  CONSTRAINT [DF_TBDEX_RUN_NUMBER_RANGE_ADDED_WHO]  DEFAULT ('DD_ECM DB-Internal') FOR [ADDED_WHO]
GO

ALTER TABLE [dbo].[TBDEX_RUN_NUMBER_RANGE] ADD  CONSTRAINT [DF_TBDEX_RUN_NUMBER_RANGE_ADDED_WHEN]  DEFAULT (getdate()) FOR [ADDED_WHEN]
GO

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

ALTER TABLE [dbo].[TBDEX_RUN_NUMBER_RANGE] CHECK CONSTRAINT [FK_TBDEX_RUN_NUMBER_RANGE_TBDEX_CFG_PROFILE]
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_RUN_NUMBER_RANGE', @level2type=N'CONSTRAINT',@level2name=N'FK_TBDEX_RUN_NUMBER_RANGE_TBDEX_CFG_PROFILE'
GO


