CREATE TABLE [dbo].[LSCrew]
(
[PriKey] [int] NOT NULL IDENTITY(1, 1),
[LSPriKey] [int] NOT NULL,
[CrewID] [int] NOT NULL,
[StartTime] [datetime] NULL,
[EndTime] [datetime] NULL,
[ActStart] [datetime] NULL,
[ActEnd] [datetime] NULL,
[LeadMan] [int] NULL,
[OverTimeStart] [datetime] NULL,
[OverTimeEnd] [datetime] NULL,
[LaborTypeFID] [int] NOT NULL,
[CrewReportTime] [datetime] NULL,
[CrewReportLocationFID] [int] NULL
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[LSCrew] ADD CONSTRAINT [PK_LSCrew] PRIMARY KEY CLUSTERED ([PriKey]) ON [PRIMARY]
GO
CREATE NONCLUSTERED INDEX [IX_LSCrew_CrewID] ON [dbo].[LSCrew] ([CrewID]) ON [PRIMARY]
GO
CREATE NONCLUSTERED INDEX [IX_LSCrew_LocServ_ServiceDate] ON [dbo].[LSCrew] ([CrewID], [PriKey], [LSPriKey]) INCLUDE ([EndTime], [StartTime]) ON [PRIMARY]
GO
CREATE NONCLUSTERED INDEX [IX_LSCrew_LSPriKey] ON [dbo].[LSCrew] ([LSPriKey]) ON [PRIMARY]
GO
CREATE NONCLUSTERED INDEX [IX_LSCrew_StartTime_CrewID] ON [dbo].[LSCrew] ([StartTime], [CrewID]) INCLUDE ([EndTime]) ON [PRIMARY]
GO
CREATE STATISTICS [STAT_LSCrew_LocServ_2] ON [dbo].[LSCrew] ([CrewID], [PriKey], [LSPriKey])
GO
CREATE STATISTICS [STAT_LSCrew_LocServ_1] ON [dbo].[LSCrew] ([LSPriKey], [PriKey])
GO
ALTER TABLE [dbo].[LSCrew] ADD CONSTRAINT [FK_LSCrew_Sysuser] FOREIGN KEY ([CrewID]) REFERENCES [dbo].[Sysuser] ([SysUserID])
GO
ALTER TABLE [dbo].[LSCrew] ADD CONSTRAINT [FK_LSCrew_CrewReportLocation] FOREIGN KEY ([CrewReportLocationFID]) REFERENCES [dbo].[CrewReportLocation] ([CrewReportLocationID])
GO
ALTER TABLE [dbo].[LSCrew] ADD CONSTRAINT [FK_LSCrew_LaborType] FOREIGN KEY ([LaborTypeFID]) REFERENCES [dbo].[LaborType] ([PriKey])
GO
ALTER TABLE [dbo].[LSCrew] ADD CONSTRAINT [FK_LSCrew_LOCSERV] FOREIGN KEY ([LSPriKey]) REFERENCES [dbo].[LocServ] ([PriKey])
GO
GRANT SELECT ON [dbo].[LSCrew] TO [MssExec]
GRANT INSERT ON [dbo].[LSCrew] TO [MssExec]
GRANT DELETE ON [dbo].[LSCrew] TO [MssExec]
GRANT UPDATE ON [dbo].[LSCrew] TO [MssExec]
GO