Tables [dbo].[Jobs]
Properties
PropertyValue
CollationSQL_Latin1_General_CP1_CI_AS
Row Count (~)0
Created4:57:07 PM Thursday, September 7, 2006
Last Modified2:15:31 PM Monday, February 3, 2014
Columns
NameData TypeMax Length (Bytes)Allow NullsIdentity
Cluster Primary Key PK_Jobs: JobsIDJobsIDint4
No
1 - 1
Foreign Keys FK_Jobs_ORDERS: [dbo].[Orders].OrdersPriKeyIndexes IX_Jobs_OrdersPriKey: OrdersPriKeyIndexes IX_Jobs_OrdersPriKey_ClientJobNo: OrdersPriKey\ClientJobNoOrdersPriKeyint4
No
Foreign Keys FK_Jobs_Stores: [dbo].[Stores].StoresIDStoresIDint4
Yes
Indexes IX_Jobs_OrdersPriKey_ClientJobNo: OrdersPriKey\ClientJobNoClientJobNovarchar(50)50
No
LabelPrintedvarchar(1)1
Yes
DCAgentIDint4
Yes
TruckNovarchar(50)50
Yes
LogisticsOrderNovarchar(50)50
Yes
PONovarchar(15)15
Yes
DCDeliveryConfirmedvarchar(1)1
Yes
DateOfDCContactdatetime8
Yes
CallToDCToDelivervarchar(1)1
Yes
FirstDayOf3DaySpreaddatetime8
Yes
StoredAtStorevarchar(1)1
Yes
DropSequencevarchar(2)2
Yes
StoreContactDatedatetime8
Yes
Commentsvarchar(60)60
Yes
PODReturnDatedatetime8
Yes
AllActionsCompletevarchar(1)1
Yes
InvoiceNovarchar(50)50
Yes
InvoiceDatedatetime8
Yes
InstallDateTimedatetime8
Yes
SchedDCDeliveryDateLdatetime8
Yes
StoreContactNamevarchar(50)50
Yes
TransFeemoney8
Yes
InvoiceSuppNoint4
Yes
Indexes Indexes
NameColumnsUniqueFill Factor
Cluster Primary Key PK_Jobs: JobsIDPK_JobsJobsID
Yes
80
IX_Jobs_OrdersPriKeyOrdersPriKey80
IX_Jobs_OrdersPriKey_ClientJobNoOrdersPriKey, ClientJobNo
Triggers Triggers
NameANSI Nulls OnQuoted Identifier OnOn
JobsTaskFieldChanged
Yes
Yes
After Update
Foreign Keys Foreign Keys
NameColumns
FK_Jobs_ORDERSOrdersPriKey->[dbo].[Orders].[PriKey]
FK_Jobs_StoresStoresID->[dbo].[Stores].[StoreID]
Permissions
TypeActionOwning Principal
GrantDeleteMssExec
GrantInsertMssExec
GrantSelectMssExec
GrantUpdateMssExec
SQL Script
CREATE TABLE [dbo].[Jobs]
(
[JobsID] [int] NOT NULL IDENTITY(1, 1),
[OrdersPriKey] [int] NOT NULL,
[StoresID] [int] NULL,
[ClientJobNo] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
[LabelPrinted] [varchar] (1) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[DCAgentID] [int] NULL,
[TruckNo] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[LogisticsOrderNo] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[PONo] [varchar] (15) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[DCDeliveryConfirmed] [varchar] (1) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[DateOfDCContact] [datetime] NULL,
[CallToDCToDeliver] [varchar] (1) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[FirstDayOf3DaySpread] [datetime] NULL,
[StoredAtStore] [varchar] (1) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[DropSequence] [varchar] (2) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[StoreContactDate] [datetime] NULL,
[Comments] [varchar] (60) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[PODReturnDate] [datetime] NULL,
[AllActionsComplete] [varchar] (1) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[InvoiceNo] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[InvoiceDate] [datetime] NULL,
[InstallDateTime] [datetime] NULL,
[SchedDCDeliveryDateL] [datetime] NULL,
[StoreContactName] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[TransFee] [money] NULL,
[InvoiceSuppNo] [int] NULL
) ON [PRIMARY]
GO

CREATE trigger [dbo].[JobsTaskFieldChanged] on [dbo].[Jobs]
after update
as
set nocount on
    if( update( DateOfDCContact ) or update( FirstDayOf3DaySpread ) or update( StoreContactDate ) or update( PODReturnDate ) or update( InvoiceDate ) or
        update( InstallDatetime ) or update( SchedDCDeliveryDateL ) )
    begin
        update ToDo set ToDo.DueDate = dbo.udfTaskDueDate( ToDo.duetype, ToDo.duedays, dbo.GetJobsDateByOrderAndType( ToDo.OrderID, inserted.JobsID, DependencyDate.FieldName ) )
        from ToDo
        inner join inserted on inserted.OrdersPriKey = ToDo.OrderID and inserted.ClientJobNo = ToDo.Identifier
        inner join DependencyDate on ToDo.DependencyDateID = DependencyDate.DependencyDateID
        where DependencyDate.TableName = 'Jobs'
    end
GO
ALTER TABLE [dbo].[Jobs] ADD CONSTRAINT [PK_Jobs] PRIMARY KEY CLUSTERED  ([JobsID]) WITH (FILLFACTOR=80) ON [PRIMARY]
GO
CREATE NONCLUSTERED INDEX [IX_Jobs_OrdersPriKey] ON [dbo].[Jobs] ([OrdersPriKey]) WITH (FILLFACTOR=80) ON [PRIMARY]
GO
CREATE NONCLUSTERED INDEX [IX_Jobs_OrdersPriKey_ClientJobNo] ON [dbo].[Jobs] ([OrdersPriKey], [ClientJobNo]) ON [PRIMARY]
GO
ALTER TABLE [dbo].[Jobs] ADD CONSTRAINT [FK_Jobs_ORDERS] FOREIGN KEY ([OrdersPriKey]) REFERENCES [dbo].[Orders] ([PriKey])
GO
ALTER TABLE [dbo].[Jobs] ADD CONSTRAINT [FK_Jobs_Stores] FOREIGN KEY ([StoresID]) REFERENCES [dbo].[Stores] ([StoreID])
GO
GRANT SELECT ON  [dbo].[Jobs] TO [MssExec]
GRANT INSERT ON  [dbo].[Jobs] TO [MssExec]
GRANT DELETE ON  [dbo].[Jobs] TO [MssExec]
GRANT UPDATE ON  [dbo].[Jobs] TO [MssExec]
GO
Uses
Used By