CREATE TABLE [dbo].[ReportLetter]
(
[ReportFID] [int] NOT NULL,
[LetterContent] [varbinary] (max) NOT NULL,
[CreatedOn] [datetime] NOT NULL,
[CreatedBy] [int] NOT NULL,
[LastEdited] [datetime] NULL,
[LastEditedBy] [int] NULL,
[TimesUsed] [int] NOT NULL CONSTRAINT [DF_ReportLetter_TimesUsed] DEFAULT ((0)),
[DocumentTypeFID] [int] NOT NULL
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO
ALTER TABLE [dbo].[ReportLetter] ADD CONSTRAINT [PK_ReportLetter] PRIMARY KEY NONCLUSTERED ([ReportFID]) ON [PRIMARY]
GO
ALTER TABLE [dbo].[ReportLetter] ADD CONSTRAINT [FK_ReportLetter_SysUser] FOREIGN KEY ([CreatedBy]) REFERENCES [dbo].[Sysuser] ([SysUserID])
GO
ALTER TABLE [dbo].[ReportLetter] ADD CONSTRAINT [FK_ReportLetter_DocumentType] FOREIGN KEY ([DocumentTypeFID]) REFERENCES [dbo].[DocumentType] ([DocumentTypeID])
GO
ALTER TABLE [dbo].[ReportLetter] ADD CONSTRAINT [FK_ReportLetter_SysUser2] FOREIGN KEY ([LastEditedBy]) REFERENCES [dbo].[Sysuser] ([SysUserID])
GO
ALTER TABLE [dbo].[ReportLetter] ADD CONSTRAINT [FK_Reports] FOREIGN KEY ([ReportFID]) REFERENCES [dbo].[Reports] ([Prikey])
GO
GRANT SELECT ON [dbo].[ReportLetter] TO [MssExec]
GRANT INSERT ON [dbo].[ReportLetter] TO [MssExec]
GRANT DELETE ON [dbo].[ReportLetter] TO [MssExec]
GRANT UPDATE ON [dbo].[ReportLetter] TO [MssExec]
GO