CREATE TABLE [dbo].[AS400_BatchMovimenti] (
    [IdxBatch]     INT             IDENTITY (1, 1) NOT NULL,
    [DataIns]      DATETIME        NOT NULL,
    [numOp]        INT             NULL,
    [CodEvento]    NVARCHAR (10)   NOT NULL,
    [Particolare]  NVARCHAR (15)   NOT NULL,
    [UDC]          NVARCHAR (50)   NOT NULL,
    [CodMagAS]     NVARCHAR (50)   NOT NULL,
    [Quantita]     DECIMAL (10, 2) NOT NULL,
    [DataBatch]    DATETIME        NULL,
    [DataVerifica] DATETIME        NULL,
    CONSTRAINT [PK_AS400_BatchMovimenti] PRIMARY KEY CLUSTERED ([IdxBatch] ASC) WITH (FILLFACTOR = 95),
    CONSTRAINT [FK_AS400_BatchMovimenti_AnagTipoEvento] FOREIGN KEY ([CodEvento]) REFERENCES [dbo].[AnagTipoEvento] ([CodEvento]) ON UPDATE CASCADE,
    CONSTRAINT [FK_AS400_BatchMovimenti_AS400_MagCont] FOREIGN KEY ([CodMagAS]) REFERENCES [dbo].[AS400_MagCont] ([CodMagAS]) ON UPDATE CASCADE
);


GO
CREATE NONCLUSTERED INDEX [IX_AS400_BatchMovimenti_DataBatch_Filter]
    ON [dbo].[AS400_BatchMovimenti]([DataBatch] ASC) WHERE ([DataBatch] IS NULL);


GO
CREATE NONCLUSTERED INDEX [IX_AS400_BatchMovimenti_numOp]
    ON [dbo].[AS400_BatchMovimenti]([numOp] ASC) WITH (FILLFACTOR = 95);


GO
EXECUTE sp_addextendedproperty @name = N'MS_Description', @value = N'dataora inserimento in coda caricamento', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'TABLE', @level1name = N'AS400_BatchMovimenti', @level2type = N'COLUMN', @level2name = N'DataIns';


GO
EXECUTE sp_addextendedproperty @name = N'MS_Description', @value = N'NON MODIFICARE: nel codice si usano questi campi x chiamate...', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'TABLE', @level1name = N'AS400_BatchMovimenti', @level2type = N'COLUMN', @level2name = N'CodEvento';


GO
EXECUTE sp_addextendedproperty @name = N'MS_Description', @value = N'dataora di caricamento batch verso AS', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'TABLE', @level1name = N'AS400_BatchMovimenti', @level2type = N'COLUMN', @level2name = N'DataBatch';


GO
EXECUTE sp_addextendedproperty @name = N'MS_Description', @value = N'dataora in cui è stato verificato il caricamento su AS', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'TABLE', @level1name = N'AS400_BatchMovimenti', @level2type = N'COLUMN', @level2name = N'DataVerifica';

