CREATE TABLE [dbo].[md_fields_regexp]
(
[fldr_table_name] [dbo].[ais_name] NOT NULL,
[fldr_field_name] [dbo].[ais_name] NOT NULL,
[fldr_regexp_code] [dbo].[ais_code_short] NOT NULL,
[fldr_rowver] [timestamp] NOT NULL,
[fldr_content] [varchar] (255) COLLATE French_CI_AS NOT NULL,
[fldr_msg] [varchar] (255) COLLATE French_CI_AS NOT NULL
) ON [PRIMARY]

ALTER TABLE [dbo].[md_fields_regexp] ADD
CONSTRAINT [CK__md_fields_regexp_fldr_regexp_code__string_pk] CHECK ((len(ltrim(rtrim([fldr_regexp_code])))>(0) AND charindex('*',[fldr_regexp_code])=(0) AND charindex('%',[fldr_regexp_code])=(0)))

GO
ALTER TABLE [dbo].[md_fields_regexp] ADD CONSTRAINT [PK_md_fields_regexp] PRIMARY KEY CLUSTERED  ([fldr_table_name], [fldr_field_name], [fldr_regexp_code]) ON [PRIMARY]
GO
ALTER TABLE [dbo].[md_fields_regexp] WITH NOCHECK ADD CONSTRAINT [FK_md_fields_regexp_md_fields] FOREIGN KEY ([fldr_table_name], [fldr_field_name]) REFERENCES [dbo].[md_fields] ([fld_table_name], [fld_field_name]) ON DELETE CASCADE
GO
ALTER TABLE [dbo].[md_fields_regexp] ADD CONSTRAINT [FK_md_fields_regexp_md_fields_cpl] FOREIGN KEY ([fldr_table_name], [fldr_field_name]) REFERENCES [dbo].[md_fields_cpl] ([fld_table_name], [fld_field_name])
GO
