CREATE TABLE [dbo].[dyn_scenarios_fields]
(
[scf_scen_code] [dbo].[ais_code_short] NOT NULL,
[scf_table_name] [dbo].[ais_name] NOT NULL,
[scf_field_name] [dbo].[ais_name] NOT NULL,
[scf_default_value] [varchar] (50) COLLATE French_CI_AS NULL,
[scf_tariff_required] [bit] NOT NULL CONSTRAINT [DF__dyn_scenarios_fields__scf_tariff_required] DEFAULT ((0)),
[scf_policy_required] [bit] NOT NULL CONSTRAINT [DF__dyn_scenarios_fields__scf_policy_required] DEFAULT ((0)),
[scf_edit_by_authorised_user] [bit] NOT NULL CONSTRAINT [DF__dyn_scenarios_fields__scf_edit_by_authorised_user] DEFAULT ((0)),
[scf_hd_company_quotation_required] [bit] NOT NULL CONSTRAINT [DF__dyn_scenarios_fields__scf_hd_company_quotation_required] DEFAULT ((0)),
[scf_hd_client_quotation_required] [bit] NOT NULL CONSTRAINT [DF__dyn_scenarios_fields__scf_hd_client_quotation_required] DEFAULT ((0)),
[scf_hd_policy_required] [bit] NOT NULL CONSTRAINT [DF__dyn_scenarios_fields__scf_hd_policy_required] DEFAULT ((0))
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[dyn_scenarios_fields] ADD CONSTRAINT [PK_dyn_scenarios_fields] PRIMARY KEY CLUSTERED  ([scf_scen_code], [scf_table_name], [scf_field_name]) ON [PRIMARY]
GO
ALTER TABLE [dbo].[dyn_scenarios_fields] ADD CONSTRAINT [FK_dyn_scenarios_fields_dyn_scenarios] FOREIGN KEY ([scf_scen_code]) REFERENCES [dbo].[dyn_scenarios] ([sc_scen_code])
GO
ALTER TABLE [dbo].[dyn_scenarios_fields] ADD CONSTRAINT [FK_dyn_scenarios_fields_md_fields_cpl] FOREIGN KEY ([scf_table_name], [scf_field_name]) REFERENCES [dbo].[md_fields_cpl] ([fld_table_name], [fld_field_name])
GO
