Tables [dbo].[LaborRatingGroup]
Properties
PropertyValue
CollationSQL_Latin1_General_CP1_CI_AS
Row Count (~)1
Created8:23:17 AM Friday, December 7, 2018
Last Modified8:51:06 AM Friday, December 7, 2018
Columns
NameData TypeMax Length (Bytes)Allow NullsIdentityDefault
Cluster Primary Key PK_LaborRatingGroup: LaborRatingGroupIDLaborRatingGroupIDint4
No
1 - 1
Indexes IX_LaborRatingGroup_Name: NameNamevarchar(100)100
No
OTAfter8Hoursbit1
No
((0))
Indexes Indexes
NameColumnsUnique
Cluster Primary Key PK_LaborRatingGroup: LaborRatingGroupIDPK_LaborRatingGroupLaborRatingGroupID
Yes
IX_LaborRatingGroup_NameName
Yes
Triggers Triggers
NameANSI Nulls OnQuoted Identifier OnOn
LaborRatingGroup_CreateEmptyScheduleWhenCreated
Yes
Yes
After Insert
Permissions
TypeActionOwning Principal
GrantDeleteMssExec
GrantInsertMssExec
GrantSelectMssExec
GrantUpdateMssExec
SQL Script
CREATE TABLE [dbo].[LaborRatingGroup]
(
[LaborRatingGroupID] [int] NOT NULL IDENTITY(1, 1),
[Name] [varchar] (100) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
[OTAfter8Hours] [bit] NOT NULL CONSTRAINT [DF_LaborRatingGroup_OTAfter8Hours] DEFAULT ((0))
) ON [PRIMARY]
GO

/*
* Pushes data to LaborRatingSchedule Query for a blank group.  All LaborRatingDays will have regular time all day.
*/

CREATE TRIGGER [dbo].[LaborRatingGroup_CreateEmptyScheduleWhenCreated]
    ON [dbo].[LaborRatingGroup]
    AFTER INSERT
    AS
    BEGIN
        set nocount on
        insert into LaborRatingScheduleQuery
        (
            LaborRatingGroupFID,
            LaborRatingDayFID,
            StartTime,
            EndTime,
            LaborRatingTypeFID
        )
        select
            LaborRatingGroupFID = inserted.LaborRatingGroupID,
            LaborRatingDayFID = LaborRatingDay.LaborRatingDayID,
            StartTime = convert(datetime, 0),
            EndTime = convert(datetime, 1),
            LaborRatingTypeFID = LaborRatingType.LaborRatingTypeID
        from inserted
        cross join LaborRatingDay
        cross join LaborRatingType
        where LaborRatingType.TypeName = 'Regular Rate'
    end
GO
ALTER TABLE [dbo].[LaborRatingGroup] ADD CONSTRAINT [PK_LaborRatingGroup] PRIMARY KEY CLUSTERED  ([LaborRatingGroupID]) ON [PRIMARY]
GO
ALTER TABLE [dbo].[LaborRatingGroup] ADD CONSTRAINT [IX_LaborRatingGroup_Name] UNIQUE NONCLUSTERED  ([Name]) ON [PRIMARY]
GO
GRANT SELECT ON  [dbo].[LaborRatingGroup] TO [MssExec]
GRANT INSERT ON  [dbo].[LaborRatingGroup] TO [MssExec]
GRANT DELETE ON  [dbo].[LaborRatingGroup] TO [MssExec]
GRANT UPDATE ON  [dbo].[LaborRatingGroup] TO [MssExec]
GO
Uses
Used By