﻿CREATE TABLE [ext].[ProductionLogRaw_KO] (
    [EventStart]    DATETIME        NOT NULL,
    [EventEnd]      DATETIME        NOT NULL,
    [CodPlant]      NVARCHAR (50)   NOT NULL,
    [ProcessNum]    NVARCHAR (50)   NOT NULL,
    [NrPos]         NVARCHAR (50)   NOT NULL,
    [CodDies]       NVARCHAR (50)   NOT NULL,
    [CodClient]     NVARCHAR (50)   NOT NULL,
    [OrderNum]      NVARCHAR (50)   NOT NULL,
    [BatchNum]      NVARCHAR (50)   NOT NULL,
    [ProcessType]   NVARCHAR (50)   NOT NULL,
    [EventType]     NVARCHAR (50)   NOT NULL,
    [RawMat]        NVARCHAR (50)   NOT NULL,
    [CodPackag]     NVARCHAR (50)   NOT NULL,
    [QtyIN]         DECIMAL (18, 4) NOT NULL,
    [QtyOUT]        DECIMAL (18, 4) NOT NULL,
    [QtyEXT]        DECIMAL (18, 4) NOT NULL,
    [NumIN]         INT             NOT NULL,
    [NumOUT]        INT             NOT NULL,
    [QuotaPlant]    DECIMAL (9, 4)  NOT NULL,
    [QuotaMan]      DECIMAL (9, 4)  NOT NULL,
    [Tags]          NVARCHAR (250)  NOT NULL,
    [okPr]          BIT             CONSTRAINT [DF_ProductionLogRaw_KO_okPr] DEFAULT ((1)) NOT NULL,
    [okQM]          BIT             CONSTRAINT [DF_ProductionLogRaw_KO_okQM] DEFAULT ((1)) NOT NULL,
    [okSc]          BIT             CONSTRAINT [DF_ProductionLogRaw_KO_okSc] DEFAULT ((1)) NOT NULL,
    [okDi]          BIT             CONSTRAINT [DF_ProductionLogRaw_KO_okDi] DEFAULT ((1)) NOT NULL,
    [ImportDateExt] DATETIME        CONSTRAINT [DF_ProductionLogRaw_KO_ImportDateExt] DEFAULT (getdate()) NULL,
    CONSTRAINT [PK_ProductionLogRaw_KO] PRIMARY KEY CLUSTERED ([EventStart] ASC, [EventEnd] ASC, [CodPlant] ASC, [ProcessNum] ASC, [NrPos] ASC, [CodDies] ASC)
);


GO
EXECUTE sp_addextendedproperty @name = N'MS_Description', @value = N'validazione riga x calcolo produttività', @level0type = N'SCHEMA', @level0name = N'ext', @level1type = N'TABLE', @level1name = N'ProductionLogRaw_KO', @level2type = N'COLUMN', @level2name = N'okPr';


GO
EXECUTE sp_addextendedproperty @name = N'MS_Description', @value = N'validazione riga x calcolo quota MAN', @level0type = N'SCHEMA', @level0name = N'ext', @level1type = N'TABLE', @level1name = N'ProductionLogRaw_KO', @level2type = N'COLUMN', @level2name = N'okQM';


GO
EXECUTE sp_addextendedproperty @name = N'MS_Description', @value = N'validazione riga x calcolo scarti', @level0type = N'SCHEMA', @level0name = N'ext', @level1type = N'TABLE', @level1name = N'ProductionLogRaw_KO', @level2type = N'COLUMN', @level2name = N'okSc';


GO
EXECUTE sp_addextendedproperty @name = N'MS_Description', @value = N'validazione riga x calcolo difettosità', @level0type = N'SCHEMA', @level0name = N'ext', @level1type = N'TABLE', @level1name = N'ProductionLogRaw_KO', @level2type = N'COLUMN', @level2name = N'okDi';

