CREATE TABLE [dbo].[ba_batches_activities]
(
[baa_batch_id] [int] NOT NULL,
[baa_name] [dbo].[ais_code_long] NOT NULL,
[baa_start_date] [datetime] NOT NULL,
[baa_end_date] [datetime] NULL,
[baa_batch_status] [dbo].[ais_code_medium] NOT NULL,
[baa_items_count] [int] NULL,
[baa_current_item] [int] NULL,
[baa_current_message] [varchar] (500) COLLATE French_CI_AS NULL
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[ba_batches_activities] ADD CONSTRAINT [CK__ba_batches_activities_baa_name__string_pk] CHECK ((len(ltrim(rtrim([baa_name])))>(0) AND charindex('*',[baa_name])=(0) AND charindex('%',[baa_name])=(0)))
GO
ALTER TABLE [dbo].[ba_batches_activities] ADD CONSTRAINT [PK_ba_batches_activities] PRIMARY KEY CLUSTERED  ([baa_batch_id], [baa_name]) ON [PRIMARY]
GO
ALTER TABLE [dbo].[ba_batches_activities] ADD CONSTRAINT [FK_ba_batches_activities_ba_batches] FOREIGN KEY ([baa_batch_id]) REFERENCES [dbo].[ba_batches] ([ba_batch_id])
GO
ALTER TABLE [dbo].[ba_batches_activities] ADD CONSTRAINT [FK_ba_batches_activities_nm_batches_statuses] FOREIGN KEY ([baa_batch_status]) REFERENCES [dbo].[nm_batches_statuses] ([nmbs_batch_status_code])
GO
