﻿CREATE TABLE [ext].[OrdersHistRaw] (
    [OrdNum]          NVARCHAR (50)   CONSTRAINT [DF_OrdersHistRaw_OrdNum] DEFAULT ((0)) NOT NULL,
    [OrdRow]          NVARCHAR (50)   CONSTRAINT [DF_OrdersHistRaw_OrdRow] DEFAULT ((0)) NOT NULL,
    [OrdDate]         SMALLDATETIME   CONSTRAINT [DF_OrdersHistRaw_OrdDate] DEFAULT (getdate()) NOT NULL,
    [CodClient]       NVARCHAR (50)   NOT NULL,
    [CodItem]         NVARCHAR (50)   CONSTRAINT [DF_OrdersHistRaw_CodItem] DEFAULT ('') NOT NULL,
    [RawMat]          NVARCHAR (50)   NOT NULL,
    [RawMatCost]      DECIMAL (18, 6) CONSTRAINT [DF_OrdersHistRaw_RawMatCost] DEFAULT ((0)) NOT NULL,
    [BatchQty]        INT             CONSTRAINT [DF_OrdersHistRaw_BatchQty] DEFAULT ((0)) NOT NULL,
    [CodInco]         NVARCHAR (5)    NOT NULL,
    [OrdPrice]        DECIMAL (9, 6)  CONSTRAINT [DF_OrdersHistRaw_OrdPrice] DEFAULT ((0)) NOT NULL,
    [RawMatExtraCost] DECIMAL (18, 6) CONSTRAINT [DF_OrdersHistRaw_RawMatExtraCost] DEFAULT ((0)) NOT NULL,
    [PriceOff]        DECIMAL (9, 6)  CONSTRAINT [DF_OrdersHistRaw_PriceOff] DEFAULT ((0)) NOT NULL,
    [OrdQty]          INT             CONSTRAINT [DF_OrdersHistRaw_OrderQty] DEFAULT ((0)) NOT NULL,
    [ProvvCost]       DECIMAL (9, 6)  CONSTRAINT [DF_OrdersHistRaw_ProvvCost] DEFAULT ((0)) NOT NULL,
    CONSTRAINT [PK_OrdersHistRaw] PRIMARY KEY CLUSTERED ([OrdNum] ASC, [OrdRow] ASC)
);

