CREATE TABLE [dbo].[Advance]
(
[PriKey] [int] NOT NULL IDENTITY(1, 1),
[AdvanceToSysUserFID] [int] NOT NULL,
[OrderFID] [int] NULL,
[TripPriKey] [int] NULL,
[AdvanceDate] [datetime] NOT NULL,
[AdvanceAmt] [money] NOT NULL,
[Reason] [varchar] (60) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[AuthBy] [int] NOT NULL,
[ReferenceNumber] [varchar] (32) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[ManualBankingServiceSendFlag] [bit] NOT NULL CONSTRAINT [DF_Advance_ManualBankingServiceSendFlag] DEFAULT ((0)),
[AdvanceBatchFID] [int] NULL,
[OffHoldDate] [datetime] NULL,
[OffHoldBy] [int] NULL,
[OffHoldDescription] [varchar] (64) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[VendorID] [varchar] (15) COLLATE SQL_Latin1_General_CP1_CI_AS NULL
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[Advance] ADD CONSTRAINT [PK_Advance] PRIMARY KEY CLUSTERED ([PriKey]) WITH (FILLFACTOR=80) ON [PRIMARY]
GO
CREATE NONCLUSTERED INDEX [IX_Advance_AdvanceToSysUserFID] ON [dbo].[Advance] ([AdvanceToSysUserFID]) ON [PRIMARY]
GO
CREATE NONCLUSTERED INDEX [IX_Advance_AuthBy] ON [dbo].[Advance] ([AuthBy]) ON [PRIMARY]
GO
ALTER TABLE [dbo].[Advance] ADD CONSTRAINT [FK_Advance_AdvanceBatch] FOREIGN KEY ([AdvanceBatchFID]) REFERENCES [dbo].[AdvanceBatch] ([AdvanceBatchID])
GO
ALTER TABLE [dbo].[Advance] ADD CONSTRAINT [FK_Advance_AdvanceToSysUserFID] FOREIGN KEY ([AdvanceToSysUserFID]) REFERENCES [dbo].[Sysuser] ([SysUserID])
GO
ALTER TABLE [dbo].[Advance] ADD CONSTRAINT [FK_Advance_AuthBy] FOREIGN KEY ([AuthBy]) REFERENCES [dbo].[Sysuser] ([SysUserID])
GO
ALTER TABLE [dbo].[Advance] ADD CONSTRAINT [FK_Advance_Sysuser] FOREIGN KEY ([AuthBy]) REFERENCES [dbo].[Sysuser] ([SysUserID])
GO
ALTER TABLE [dbo].[Advance] ADD CONSTRAINT [FK_Advance_Orders] FOREIGN KEY ([OrderFID]) REFERENCES [dbo].[Orders] ([PriKey])
GO
ALTER TABLE [dbo].[Advance] ADD CONSTRAINT [FK_Advance_Trips] FOREIGN KEY ([TripPriKey]) REFERENCES [dbo].[Trips] ([PriKey])
GO
GRANT SELECT ON [dbo].[Advance] TO [MssExec]
GRANT INSERT ON [dbo].[Advance] TO [MssExec]
GRANT DELETE ON [dbo].[Advance] TO [MssExec]
GRANT UPDATE ON [dbo].[Advance] TO [MssExec]
GO