CREATE TABLE [dbo].[md_link_values]
(
[lval_link_table_name] [dbo].[ais_name] NOT NULL,
[lval_value] [dbo].[ais_code_short] NOT NULL,
[lval_rowver] [timestamp] NOT NULL,
[lval_l1] [nvarchar] (256) COLLATE French_CI_AS NOT NULL,
[lval_l2] [nvarchar] (256) COLLATE French_CI_AS NULL,
[lval_l3] [nvarchar] (256) COLLATE French_CI_AS NULL
) ON [PRIMARY]
ALTER TABLE [dbo].[md_link_values] ADD
CONSTRAINT [FK_md_link_values_md_link_tables] FOREIGN KEY ([lval_link_table_name]) REFERENCES [dbo].[md_link_tables] ([ltbl_link_table_name]) ON UPDATE CASCADE

ALTER TABLE [dbo].[md_link_values] ADD
CONSTRAINT [CK__md_link_values_lval_value__string_pk] CHECK ((len(ltrim(rtrim([lval_value])))>(0) AND charindex('*',[lval_value])=(0) AND charindex('%',[lval_value])=(0)))
GO
ALTER TABLE [dbo].[md_link_values] ADD CONSTRAINT [PK_md_link_values] PRIMARY KEY CLUSTERED  ([lval_link_table_name], [lval_value]) ON [PRIMARY]
GO
