﻿CREATE TABLE [dbo].[WorkOrderRouting]
(
    [UserID] VARCHAR(40) NOT NULL, 
    [BatchNumber] VARCHAR(60) NOT NULL, 
    [TransactionNumber] VARCHAR(88) NOT NULL, 
    [LineNumber] INT NOT NULL,
	[StepNumber] DECIMAL(7, 2) NOT NULL, 
    [WorkCenterCode] VARCHAR(12) NOT NULL, 
    [WorkOrderNumber] BIGINT NOT NULL, 
    [RoutingType] VARCHAR(12) NULL, 
    [BranchCode] VARCHAR(12) NULL, 
    [StepDescription] VARCHAR(120) NULL, 
    [FunctionCode] VARCHAR(60) NULL, 
    [TransactionDate] DATETIME NOT NULL, 
    [LastUpdateDT] DATETIME NOT NULL, 
	CONSTRAINT [PK_WorkOrderRouting] PRIMARY KEY CLUSTERED([UserID], [BatchNumber], [TransactionNumber], [LineNumber], [StepNumber], [WorkCenterCode])
)
GO

CREATE INDEX [IX_WorkOrderRouting_Lookup] ON [dbo].[WorkOrderRouting] ([WorkOrderNumber], [WorkCenterCode], [FunctionCode]) INCLUDE([StepNumber])
GO