Tables [dbo].[OfficeIndustrialOrder]
Properties
PropertyValue
CollationSQL_Latin1_General_CP1_CI_AS
HeapYes
Row Count (~)0
Created8:53:30 AM Friday, December 7, 2018
Last Modified7:37:19 PM Wednesday, February 28, 2024
Columns
NameData TypeMax Length (Bytes)Allow NullsIdentity
Primary Key PK_OfficeIndustrialOrder: OfficeIndustrialOrderIDOfficeIndustrialOrderIDint4
No
1 - 1
Foreign Keys FK_OfficeIndustrialOrder_Orders: [dbo].[Orders].OrderFIDIndexes IX_OfficeIndustrialOrder_OrderFID: OrderFIDOrderFIDint4
No
Foreign Keys FK_OfficeIndustrialOrder_Sysuser: [dbo].[Sysuser].ProjectManagerProjectManagerint4
Yes
JobStartDatedatetime8
Yes
JobEndDatedatetime8
Yes
HeadCountint4
Yes
ClientNotevarchar(max)max
Yes
OperationalNotevarchar(max)max
Yes
Indexes Indexes
NameColumnsUnique
Primary Key PK_OfficeIndustrialOrder: OfficeIndustrialOrderIDPK_OfficeIndustrialOrderOfficeIndustrialOrderID
Yes
IX_OfficeIndustrialOrder_OrderFIDOrderFID
Yes
Triggers Triggers
NameANSI Nulls OnQuoted Identifier OnOn
OfficeIndustrialOrderTaskFieldChanged
Yes
Yes
After Insert Update
Foreign Keys Foreign Keys
NameColumns
FK_OfficeIndustrialOrder_OrdersOrderFID->[dbo].[Orders].[PriKey]
FK_OfficeIndustrialOrder_SysuserProjectManager->[dbo].[Sysuser].[SysUserID]
Permissions
TypeActionOwning Principal
GrantDeleteMssExec
GrantInsertMssExec
GrantSelectMssExec
GrantUpdateMssExec
SQL Script
CREATE TABLE [dbo].[OfficeIndustrialOrder]
(
[OfficeIndustrialOrderID] [int] NOT NULL IDENTITY(1, 1),
[OrderFID] [int] NOT NULL,
[ProjectManager] [int] NULL,
[JobStartDate] [datetime] NULL,
[JobEndDate] [datetime] NULL,
[HeadCount] [int] NULL,
[ClientNote] [varchar] (max) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[OperationalNote] [varchar] (max) COLLATE SQL_Latin1_General_CP1_CI_AS NULL
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO

CREATE trigger [dbo].[OfficeIndustrialOrderTaskFieldChanged] on [dbo].[OfficeIndustrialOrder]
after insert, update
as
set nocount on
    if( update( JobStartDate ) or update( JobEndDate ) )
    begin
        update ToDo set ToDo.DueDate =
            case DependencyDate.FieldName
                when 'JobStartDate' then dbo.udfTaskDueDate( ToDo.DueType, ToDo.DueDays, inserted.JobStartDate )
                when 'JobEndDate' then dbo.udfTaskDueDate( ToDo.DueType, ToDo.DueDays, inserted.JobEndDate )
                else ToDo.DueDate
            end
        from ToDo
        inner join inserted on inserted.OrderFID = ToDo.OrderID
        inner join DependencyDate on ToDo.DependencyDateID = DependencyDate.DependencyDateID
        where DependencyDate.TableName = 'OfficeIndustrialOrder'
    end
    if( update( ProjectManager ) )
    begin
        update ToDo set TaskUserFID =
            case CoordinatorType.FieldName
                when 'ProjectManager' then inserted.ProjectManager
            end
        from ToDo
        inner join inserted on inserted.OrderFID = ToDo.OrderID
        inner join CoordinatorType on ToDo.CoordinatorTypeFID = CoordinatorType.CoordinatorTypeID
        where CoordinatorType.TableName = 'OfficeIndustrialOrder'
    end
GO
ALTER TABLE [dbo].[OfficeIndustrialOrder] ADD CONSTRAINT [PK_OfficeIndustrialOrder] PRIMARY KEY NONCLUSTERED  ([OfficeIndustrialOrderID]) ON [PRIMARY]
GO
CREATE UNIQUE NONCLUSTERED INDEX [IX_OfficeIndustrialOrder_OrderFID] ON [dbo].[OfficeIndustrialOrder] ([OrderFID]) ON [PRIMARY]
GO
ALTER TABLE [dbo].[OfficeIndustrialOrder] ADD CONSTRAINT [FK_OfficeIndustrialOrder_Orders] FOREIGN KEY ([OrderFID]) REFERENCES [dbo].[Orders] ([PriKey])
GO
ALTER TABLE [dbo].[OfficeIndustrialOrder] ADD CONSTRAINT [FK_OfficeIndustrialOrder_Sysuser] FOREIGN KEY ([ProjectManager]) REFERENCES [dbo].[Sysuser] ([SysUserID])
GO
GRANT SELECT ON  [dbo].[OfficeIndustrialOrder] TO [MssExec]
GRANT INSERT ON  [dbo].[OfficeIndustrialOrder] TO [MssExec]
GRANT DELETE ON  [dbo].[OfficeIndustrialOrder] TO [MssExec]
GRANT UPDATE ON  [dbo].[OfficeIndustrialOrder] TO [MssExec]
GO
Uses
Used By