﻿CREATE TABLE [dbo].[WorkOrder_Hist]
(
	[WorkOrderNumber] BIGINT NOT NULL, 
	[BranchCode] VARCHAR(12) NULL,
    [LotNumber] VARCHAR(30) NULL,
	[ItemNumber] VARCHAR(25) NULL, 
	[ShortItemNumber] BIGINT NOT NULL,
    [ParentWorkOrderNumber] VARCHAR(8) NULL, 
    [OrderQuantity] DECIMAL(15, 2) NOT NULL, 
    [HeldQuantity] DECIMAL(15, 2) NOT NULL, 
    [ShippedQuantity] DECIMAL(15, 2) NOT NULL, 
    [StatusCode] VARCHAR(10) NULL, 
    [StatusCodeUpdateDT] DATETIME NULL,
	[IssueDate] DATETIME NOT NULL,
	[StartDate] DATETIME NOT NULL ,
	[RoutingType] VARCHAR(3) NULL,
	[LastUpdateDT] DATETIME NOT NULL, 
	CONSTRAINT [PK_WorkOrder_Hist] PRIMARY KEY CLUSTERED([WorkOrderNumber])
)
GO

CREATE INDEX [IX_WorkOrder_Hist_ParentWorkOrderNumber] ON [dbo].[WorkOrder_Hist] ([ParentWorkOrderNumber])
GO

CREATE INDEX [IX_WorkOrder_Hist_ItemNumber] ON [dbo].[WorkOrder_Hist] ([ItemNumber])
GO
