CREATE TABLE [dbo].[act_accounts]
(
[acc_actor_id] [int] NOT NULL,
[acc_account_number] [varchar] (50) COLLATE French_CI_AS NOT NULL,
[acc_rowver] [timestamp] NOT NULL,
[acc_bank_id] [int] NOT NULL,
[acc_currency_code] [dbo].[ais_code_short] NOT NULL,
[acc_bic] [varchar] (11) COLLATE French_CI_AS NULL,
[acc_iban] [varchar] (40) COLLATE French_CI_AS NULL,
[acc_holder] [varchar] (50) COLLATE French_CI_AS NULL,
[acc_residence] [varchar] (255) COLLATE French_CI_AS NULL,
[acc_bank_counter] [dbo].[ais_code_short] NULL,
[acc_bank_counter_2] [varchar] (255) COLLATE French_CI_AS NULL,
[acc_account_key] [dbo].[ais_code_short] NULL,
[acc_info] [varchar] (255) COLLATE French_CI_AS NULL,
[acc_freeze] [bit] NOT NULL CONSTRAINT [DF__act_accounts__acc_freeze] DEFAULT ((0)),
[acc_mandat_number] [varchar] (35) COLLATE French_CI_AS NULL,
[acc_mandat_sign_date] [datetime] NULL,
[acc_use_for_monthly_dues] [bit] NOT NULL CONSTRAINT [DF__act_accounts__acc_use_for_monthly_dues] DEFAULT ((0)),
[acc_issuer] [varchar] (6) COLLATE French_CI_AS NULL,
[acc_ics] [varchar] (13) COLLATE French_CI_AS NULL,
[acc_mandat_sequence_code] [dbo].[ais_code_short] NULL
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[act_accounts] ADD CONSTRAINT [CK__act_accounts_acc_account_number__string_pk] CHECK ((len(ltrim(rtrim([acc_account_number])))>(0) AND charindex('*',[acc_account_number])=(0) AND charindex('%',[acc_account_number])=(0)))
GO
ALTER TABLE [dbo].[act_accounts] ADD CONSTRAINT [PK_act_accounts] PRIMARY KEY CLUSTERED ([acc_actor_id], [acc_account_number]) ON [PRIMARY]
GO
ALTER TABLE [dbo].[act_accounts] ADD CONSTRAINT [FK_act_accounts_acc_currencies] FOREIGN KEY ([acc_currency_code]) REFERENCES [dbo].[acc_currencies] ([cur_currency_code])
GO
ALTER TABLE [dbo].[act_accounts] ADD CONSTRAINT [FK_act_accounts_act_actors] FOREIGN KEY ([acc_actor_id]) REFERENCES [dbo].[act_actors] ([act_actor_id])
GO
ALTER TABLE [dbo].[act_accounts] ADD CONSTRAINT [FK_act_accounts_act_banks] FOREIGN KEY ([acc_bank_id]) REFERENCES [dbo].[act_banks] ([bk_actor_id])
GO
