[dbo].[DocumentAutoUploadRuleDetailBranch]
CREATE TABLE [dbo].[DocumentAutoUploadRuleDetailBranch]
(
[DocumentAutoUploadRuleDetailBranchID] [int] NOT NULL IDENTITY(1, 1),
[DocumentAutoUploadRuleDetailFID] [int] NOT NULL,
[BranchFID] [int] NOT NULL
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[DocumentAutoUploadRuleDetailBranch] ADD CONSTRAINT [PK_DocumentAutoUploadRuleDetailBranch] PRIMARY KEY CLUSTERED ([DocumentAutoUploadRuleDetailBranchID]) ON [PRIMARY]
GO
CREATE NONCLUSTERED INDEX [IX_DocumentAutoUploadRuleDetailBranch_Branch] ON [dbo].[DocumentAutoUploadRuleDetailBranch] ([BranchFID]) ON [PRIMARY]
GO
CREATE UNIQUE NONCLUSTERED INDEX [IX_DocumentAutoUploadRuleDetailBranch_RuleDetail] ON [dbo].[DocumentAutoUploadRuleDetailBranch] ([DocumentAutoUploadRuleDetailFID], [BranchFID]) ON [PRIMARY]
GO
ALTER TABLE [dbo].[DocumentAutoUploadRuleDetailBranch] ADD CONSTRAINT [FK_DocumentAutoUploadRuleDetailBranch_Branch] FOREIGN KEY ([BranchFID]) REFERENCES [dbo].[Branch] ([BranchPriKey]) ON DELETE CASCADE
GO
ALTER TABLE [dbo].[DocumentAutoUploadRuleDetailBranch] ADD CONSTRAINT [FK_DocumentAutoUploadRuleDetailBranch_DocumentAutoUploadRuleDetail] FOREIGN KEY ([DocumentAutoUploadRuleDetailFID]) REFERENCES [dbo].[DocumentAutoUploadRuleDetail] ([DocumentAutoUploadRuleDetailID]) ON DELETE CASCADE
GO
GRANT SELECT ON [dbo].[DocumentAutoUploadRuleDetailBranch] TO [MssExec]
GRANT INSERT ON [dbo].[DocumentAutoUploadRuleDetailBranch] TO [MssExec]
GRANT DELETE ON [dbo].[DocumentAutoUploadRuleDetailBranch] TO [MssExec]
GRANT UPDATE ON [dbo].[DocumentAutoUploadRuleDetailBranch] TO [MssExec]
GO