# Table: WorkOrder

## Properties

Property | Value
--- | ---
Name | WorkOrder
ID | 590625147
Owner | dbo
Schema | Production
Filegroup | PRIMARY
Data Size (KB) | 4184 KB
Index Size (KB) | 1704 KB
Rows | 72591
Unused (KB) | 280 KB
ANSI Null On |
Quoted Identifier |
Lock Escalation | TABLE
Lock On Bulk Load |
Lob Data Space |
Filestream Data Space ID |
Has Unchecked Assembly Data |
Text In Row Limit (bytes) | Option not set
Large Value Types Out Of Row |
FullText Change Tracking On |
Tracked By Cdc |
Published |
Schema Published |
Replicated |
Replication Filter |
Merge Published |
Sync Tran Subscribed |
MS Shipped |
Modify Date | 8/8/2010 5:23:44 PM
Create Date | 8/8/2010 5:21:54 PM

## Extended Properties

Name | Value
--- | ---
MS_Description | Manufacturing work orders.

## Columns

Column ID | Column Name | Datatype | Nullable | Is Sparse | Is Column Set
--- | --- | --- | --- | --- | ---
1 | WorkOrderID | int |  |  |
2 | ProductID | int |  |  |
3 | OrderQty | int |  |  |
4 | StockedQty | int |  |  |
5 | ScrappedQty | smallint |  |  |
6 | StartDate | datetime |  |  |
7 | EndDate | datetime |  |  |
8 | DueDate | datetime |  |  |
9 | ScrapReasonID | smallint |  |  |
10 | ModifiedDate | datetime |  |  |

## Identity Columns

Column | Seed Value | Increment Value | Last Value | Is Not For Replication | Is Computed | Is Sparse | Is Column Set
--- | --- | --- | --- | --- | --- | --- | ---
WorkOrderID | 1 | 1 | 72591 |  |  |  |

## Primary Key Constraints

Name | Is System Named | Extended Property Name | Extended Property Value
--- | --- | --- | ---
PK_WorkOrder_WorkOrderID |  | MS_Description | Primary key (clustered) constraint

## Primary Key Columns

Name
WorkOrderID

## Foreign Keys

Name | Referenced Object | Update Action | Delete Action
--- | --- | --- | ---
FK_WorkOrder_Product_ProductID | Production.Product | No action | No action
FK_WorkOrder_ScrapReason_ScrapReasonID | Production.ScrapReason | No action | No action

## Column Level Check Constraints

Name | Column ID | Column | Definition | Is Disabled | Is Not For Replication | Is Not Trusted | Uses Database Collation | Is System Named
--- | --- | --- | --- | --- | --- | --- | --- | ---
CK_WorkOrder_OrderQty | 3 | OrderQty | ([OrderQty]>(0)) |  |  |  |  |
CK_WorkOrder_ScrappedQty | 5 | ScrappedQty | ([ScrappedQty]>=(0)) |  |  |  |  |

## Table Level Check Constraints

Name | Definition | Is Disabled | Is Not For Replication | Is Not Trusted | Uses Database Collation | Is System Named
--- | --- | --- | --- | --- | --- | ---
CK_WorkOrder_EndDate | ([EndDate]>=[StartDate] OR [EndDate] IS NULL) |  |  |  |  |

## Default Constraints

Name | Column | Definition | Is System Named | Extended Property Name | Extended Property Value
--- | --- | --- | --- | --- | ---
DF_WorkOrder_ModifiedDate | ModifiedDate | (getdate()) |  | MS_Description | Default constraint value of GETDATE()

## Indexes

Name | Index Type | Primary Key | Unique | Unique Constraint | Ignore Duplicate Key | Disabled
--- | --- | --- | --- | --- | --- | ---
PK_WorkOrder_WorkOrderID | CLUSTERED |  |  |  |  |
IX_WorkOrder_ScrapReasonID | NONCLUSTERED |  |  |  |  |
IX_WorkOrder_ProductID | NONCLUSTERED |  |  |  |  |

## FullText Indexes

No fulltext indexes defined.

## Referencing Tables

Name | Key Index ID | Is Disabled | Is Not For Replication | Is Not Trusted | Delete Action | Update Action | Is System Named | Referencing Object
--- | --- | --- | --- | --- | --- | --- | --- | ---
FK_WorkOrderRouting_WorkOrder_WorkOrderID | 1 |  |  |  | No action | No action |  | Production.WorkOrderRouting

## Object Level Permissions

No object level permissions defined.

## Column Level Permissions

No explicit column permissions granted to this object

## Statistics

### Detailed Statistics General

Name | Updated | Rows | Rows Sampled | Steps | Density | Average Key Length | String Index | Filter Expression | Unfiltered Rows
--- | --- | --- | --- | --- | --- | --- | --- | --- | ---
PK_WorkOrder_WorkOrderID | Aug 8 2010 5:23PM | 72591 | 72591 | 3 | 1 | 4 |  |  | 72591

### Detailed Statistics Density

All Density | Average Length | Columns
--- | --- | ---
1.377581E-05 | 4 | WorkOrderID

### Detailed Statistics Histogram

Range High Key | Range Rows | Estimated Rows | Distinct Range Rows | Avg Range Rows
--- | --- | --- | --- | ---
1 | 0 | 1 | 0 | 1
72590 | 72588 | 1 | 72588 | 1
72591 | 0 | 1 | 0 | 1

### Detailed Statistics General

Name | Updated | Rows | Rows Sampled | Steps | Density | Average Key Length | String Index | Filter Expression | Unfiltered Rows
--- | --- | --- | --- | --- | --- | --- | --- | --- | ---
IX_WorkOrder_ScrapReasonID | Aug 8 2010 5:23PM | 72591 | 72591 | 16 | 0.02380952 | 4.020085 |  |  | 72591

### Detailed Statistics Density

All Density | Average Length | Columns
--- | --- | ---
0.05882353 | 0.02008513 | ScrapReasonID
1.377581E-05 | 4.020085 | ScrapReasonID, WorkOrderID

### Detailed Statistics Histogram

Range High Key | Range Rows | Estimated Rows | Distinct Range Rows | Avg Range Rows
--- | --- | --- | --- | ---
| 0 | 71862 | 0 | 1
1 | 0 | 44 | 0 | 1
2 | 0 | 44 | 0 | 1
3 | 0 | 54 | 0 | 1
4 | 0 | 45 | 0 | 1
6 | 42 | 44 | 1 | 42
7 | 0 | 32 | 0 | 1
8 | 0 | 37 | 0 | 1
9 | 0 | 47 | 0 | 1
10 | 0 | 37 | 0 | 1
11 | 0 | 52 | 0 | 1
12 | 0 | 37 | 0 | 1
13 | 0 | 63 | 0 | 1
14 | 0 | 52 | 0 | 1
15 | 0 | 48 | 0 | 1
16 | 0 | 51 | 0 | 1

### Detailed Statistics General

Name | Updated | Rows | Rows Sampled | Steps | Density | Average Key Length | String Index | Filter Expression | Unfiltered Rows
--- | --- | --- | --- | --- | --- | --- | --- | --- | ---
IX_WorkOrder_ProductID | Aug 8 2010 5:23PM | 72591 | 72591 | 200 | 0.02111111 | 8 |  |  | 72591

### Detailed Statistics Density

All Density | Average Length | Columns
--- | --- | ---
0.004201681 | 4 | ProductID
1.377581E-05 | 8 | ProductID, WorkOrderID

### Detailed Statistics Histogram

Range High Key | Range Rows | Estimated Rows | Distinct Range Rows | Avg Range Rows
--- | --- | --- | --- | ---
3 | 0 | 1093 | 0 | 1
316 | 0 | 1093 | 0 | 1
324 | 0 | 1093 | 0 | 1
327 | 0 | 1093 | 0 | 1
328 | 0 | 926 | 0 | 1
329 | 0 | 1088 | 0 | 1
330 | 0 | 365 | 0 | 1
331 | 0 | 1093 | 0 | 1
350 | 0 | 1093 | 0 | 1
398 | 0 | 1093 | 0 | 1
399 | 0 | 1093 | 0 | 1
400 | 0 | 824 | 0 | 1
401 | 0 | 1092 | 0 | 1
514 | 0 | 326 | 0 | 1
515 | 0 | 12 | 0 | 1
516 | 0 | 926 | 0 | 1
517 | 0 | 815 | 0 | 1
518 | 0 | 602 | 0 | 1
519 | 0 | 1013 | 0 | 1
520 | 0 | 280 | 0 | 1
521 | 0 | 229 | 0 | 1
522 | 0 | 343 | 0 | 1
529 | 0 | 1093 | 0 | 1
531 | 0 | 1093 | 0 | 1
532 | 0 | 1093 | 0 | 1
533 | 0 | 1093 | 0 | 1
534 | 0 | 1093 | 0 | 1
680 | 0 | 245 | 0 | 1
706 | 0 | 253 | 0 | 1
717 | 0 | 243 | 0 | 1
718 | 0 | 357 | 0 | 1
719 | 0 | 370 | 0 | 1
720 | 0 | 323 | 0 | 1
721 | 0 | 203 | 0 | 1
722 | 0 | 351 | 0 | 1
723 | 0 | 101 | 0 | 1
724 | 0 | 81 | 0 | 1
725 | 0 | 114 | 0 | 1
726 | 0 | 125 | 0 | 1
727 | 0 | 94 | 0 | 1
728 | 0 | 86 | 0 | 1
729 | 0 | 104 | 0 | 1
730 | 0 | 127 | 0 | 1
731 | 0 | 12 | 0 | 1
733 | 21 | 21 | 1 | 21
736 | 24 | 340 | 2 | 12
737 | 0 | 311 | 0 | 1
738 | 0 | 374 | 0 | 1
739 | 0 | 458 | 0 | 1
742 | 111 | 412 | 2 | 55.5
743 | 0 | 485 | 0 | 1
744 | 0 | 69 | 0 | 1
745 | 0 | 76 | 0 | 1
746 | 0 | 403 | 0 | 1
747 | 0 | 467 | 0 | 1
748 | 0 | 479 | 0 | 1
749 | 0 | 219 | 0 | 1
750 | 0 | 206 | 0 | 1
751 | 0 | 227 | 0 | 1
752 | 0 | 206 | 0 | 1
753 | 0 | 203 | 0 | 1
758 | 45 | 12 | 4 | 11.25
759 | 0 | 86 | 0 | 1
760 | 0 | 79 | 0 | 1
761 | 0 | 101 | 0 | 1
762 | 0 | 90 | 0 | 1
763 | 0 | 99 | 0 | 1
764 | 0 | 80 | 0 | 1
766 | 94 | 94 | 1 | 94
768 | 81 | 81 | 1 | 81
769 | 0 | 76 | 0 | 1
770 | 0 | 108 | 0 | 1
773 | 103 | 54 | 2 | 51.5
774 | 0 | 45 | 0 | 1
775 | 0 | 56 | 0 | 1
776 | 0 | 51 | 0 | 1
779 | 127 | 390 | 2 | 63.5
780 | 0 | 384 | 0 | 1
781 | 0 | 376 | 0 | 1
782 | 0 | 377 | 0 | 1
783 | 0 | 398 | 0 | 1
784 | 0 | 403 | 0 | 1
789 | 48 | 127 | 4 | 12
790 | 0 | 137 | 0 | 1
791 | 0 | 117 | 0 | 1
792 | 0 | 253 | 0 | 1
793 | 0 | 242 | 0 | 1
794 | 0 | 250 | 0 | 1
795 | 0 | 276 | 0 | 1
796 | 0 | 245 | 0 | 1
797 | 0 | 240 | 0 | 1
798 | 0 | 225 | 0 | 1
799 | 0 | 249 | 0 | 1
800 | 0 | 235 | 0 | 1
801 | 0 | 225 | 0 | 1
802 | 0 | 832 | 0 | 1
803 | 0 | 603 | 0 | 1
804 | 0 | 1104 | 0 | 1
805 | 0 | 370 | 0 | 1
806 | 0 | 925 | 0 | 1
807 | 0 | 716 | 0 | 1
808 | 0 | 350 | 0 | 1
809 | 0 | 36 | 0 | 1
810 | 0 | 944 | 0 | 1
811 | 0 | 821 | 0 | 1
812 | 0 | 602 | 0 | 1
813 | 0 | 1031 | 0 | 1
814 | 0 | 24 | 0 | 1
815 | 0 | 338 | 0 | 1
816 | 0 | 707 | 0 | 1
817 | 0 | 237 | 0 | 1
818 | 0 | 815 | 0 | 1
819 | 0 | 612 | 0 | 1
820 | 0 | 1025 | 0 | 1
821 | 0 | 365 | 0 | 1
822 | 0 | 265 | 0 | 1
823 | 0 | 335 | 0 | 1
824 | 0 | 711 | 0 | 1
825 | 0 | 240 | 0 | 1
826 | 0 | 829 | 0 | 1
827 | 0 | 605 | 0 | 1
828 | 0 | 1017 | 0 | 1
829 | 0 | 365 | 0 | 1
830 | 0 | 15 | 0 | 1
833 | 49 | 335 | 2 | 24.5
834 | 0 | 334 | 0 | 1
835 | 0 | 344 | 0 | 1
836 | 0 | 359 | 0 | 1
838 | 0 | 260 | 0 | 1
839 | 0 | 256 | 0 | 1
840 | 0 | 276 | 0 | 1
885 | 0 | 143 | 0 | 1
886 | 0 | 69 | 0 | 1
887 | 0 | 151 | 0 | 1
888 | 0 | 142 | 0 | 1
889 | 0 | 144 | 0 | 1
890 | 0 | 196 | 0 | 1
891 | 0 | 209 | 0 | 1
892 | 0 | 188 | 0 | 1
893 | 0 | 184 | 0 | 1
894 | 0 | 1102 | 0 | 1
895 | 0 | 65 | 0 | 1
896 | 0 | 75 | 0 | 1
898 | 66 | 70 | 1 | 66
900 | 74 | 75 | 1 | 74
903 | 109 | 63 | 2 | 54.5
904 | 0 | 130 | 0 | 1
905 | 0 | 135 | 0 | 1
906 | 0 | 131 | 0 | 1
917 | 0 | 67 | 0 | 1
920 | 117 | 67 | 2 | 58.5
925 | 70 | 71 | 1 | 70
926 | 0 | 76 | 0 | 1
927 | 0 | 53 | 0 | 1
942 | 0 | 133 | 0 | 1
945 | 122 | 1105 | 2 | 61
946 | 0 | 283 | 0 | 1
947 | 0 | 366 | 0 | 1
949 | 0 | 376 | 0 | 1
950 | 0 | 916 | 0 | 1
951 | 0 | 716 | 0 | 1
953 | 0 | 83 | 0 | 1
954 | 0 | 143 | 0 | 1
955 | 0 | 134 | 0 | 1
956 | 0 | 132 | 0 | 1
957 | 0 | 131 | 0 | 1
959 | 63 | 65 | 1 | 63
960 | 0 | 67 | 0 | 1
963 | 125 | 56 | 2 | 62.5
964 | 0 | 50 | 0 | 1
965 | 0 | 57 | 0 | 1
966 | 0 | 134 | 0 | 1
967 | 0 | 139 | 0 | 1
968 | 0 | 130 | 0 | 1
969 | 0 | 131 | 0 | 1
970 | 0 | 89 | 0 | 1
971 | 0 | 101 | 0 | 1
972 | 0 | 88 | 0 | 1
973 | 0 | 181 | 0 | 1
974 | 0 | 165 | 0 | 1
975 | 0 | 165 | 0 | 1
976 | 0 | 174 | 0 | 1
977 | 0 | 225 | 0 | 1
978 | 0 | 60 | 0 | 1
979 | 0 | 53 | 0 | 1
980 | 0 | 131 | 0 | 1
981 | 0 | 118 | 0 | 1
983 | 123 | 122 | 1 | 123
984 | 0 | 50 | 0 | 1
985 | 0 | 55 | 0 | 1
986 | 0 | 49 | 0 | 1
989 | 111 | 58 | 2 | 55.5
992 | 117 | 67 | 2 | 58.5
993 | 0 | 51 | 0 | 1
994 | 0 | 878 | 0 | 1
995 | 0 | 710 | 0 | 1
996 | 0 | 1084 | 0 | 1
997 | 0 | 236 | 0 | 1
998 | 0 | 236 | 0 | 1
999 | 0 | 233 | 0 | 1

## Objects that depend on [WorkOrder]

- Production.WorkOrder
  - Production.iWorkOrder
  - Production.uWorkOrder
  - Production.WorkOrderRouting

## Objects on which [WorkOrder] depends

- Production.WorkOrder
  - Production.TransactionHistory
    - Production.Product
      - Production.ProductSubcategory
        - Production.ProductCategory
          - dbo.Name
      - Production.ProductModel
        - Production.ManuInstructionsSchemaCollection
        - Production.ProductDescriptionSchemaCollection
      - Production.UnitMeasure
      - dbo.Flag
    - datePS
      - dataPF1
  - Production.ScrapReason
  - dbo.uspLogError
    - dbo.uspPrintError
    - dbo.ErrorLog

## SQL

Script
SET ANSI_NULLS ON SET QUOTED_IDENTIFIER ON CREATE TABLE [Production].[WorkOrder]( [WorkOrderID] [int] IDENTITY(1,1) NOT NULL, [ProductID] [int] NOT NULL, [OrderQty] [int] NOT NULL, [StockedQty] AS (isnull([OrderQty]-[ScrappedQty],(0))), [ScrappedQty] [smallint] NOT NULL, [StartDate] [datetime] NOT NULL, [EndDate] [datetime] NULL, [DueDate] [datetime] NOT NULL, [ScrapReasonID] [smallint] NULL, [ModifiedDate] [datetime] NOT NULL ) ON [PRIMARY] EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'Primary key for WorkOrder records.' , @level0type=N'SCHEMA',@level0name=N'Production', @level1type=N'TABLE',@level1name=N'WorkOrder', @level2type=N'COLUMN',@level2name=N'WorkOrderID' EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'Product identification number. Foreign key to Product.ProductID.' , @level0type=N'SCHEMA',@level0name=N'Production', @level1type=N'TABLE',@level1name=N'WorkOrder', @level2type=N'COLUMN',@level2name=N'ProductID' EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'Product quantity to build.' , @level0type=N'SCHEMA',@level0name=N'Production', @level1type=N'TABLE',@level1name=N'WorkOrder', @level2type=N'COLUMN',@level2name=N'OrderQty' EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'Quantity built and put in inventory.' , @level0type=N'SCHEMA',@level0name=N'Production', @level1type=N'TABLE',@level1name=N'WorkOrder', @level2type=N'COLUMN',@level2name=N'StockedQty' EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'Quantity that failed inspection.' , @level0type=N'SCHEMA',@level0name=N'Production', @level1type=N'TABLE',@level1name=N'WorkOrder', @level2type=N'COLUMN',@level2name=N'ScrappedQty' EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'Work order start date.' , @level0type=N'SCHEMA',@level0name=N'Production', @level1type=N'TABLE',@level1name=N'WorkOrder', @level2type=N'COLUMN',@level2name=N'StartDate' EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'Work order end date.' , @level0type=N'SCHEMA',@level0name=N'Production', @level1type=N'TABLE',@level1name=N'WorkOrder', @level2type=N'COLUMN',@level2name=N'EndDate' EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'Work order due date.' , @level0type=N'SCHEMA',@level0name=N'Production', @level1type=N'TABLE',@level1name=N'WorkOrder', @level2type=N'COLUMN',@level2name=N'DueDate' EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'Reason for inspection failure.' , @level0type=N'SCHEMA',@level0name=N'Production', @level1type=N'TABLE',@level1name=N'WorkOrder', @level2type=N'COLUMN',@level2name=N'ScrapReasonID' EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'Date and time the record was last updated.' , @level0type=N'SCHEMA',@level0name=N'Production', @level1type=N'TABLE',@level1name=N'WorkOrder', @level2type=N'COLUMN',@level2name=N'ModifiedDate' EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'Manufacturing work orders.' , @level0type=N'SCHEMA',@level0name=N'Production', @level1type=N'TABLE',@level1name=N'WorkOrder'

#### See also

List of Tables