CREATE TABLE [dbo].[XmlImportHistory]
(
[XmlImportHistoryID] [int] NOT NULL IDENTITY(1, 1),
[XmlInterfaceFID] [int] NULL,
[DateDownloaded] [datetime] NOT NULL,
[OrderFID] [int] NULL,
[ErrorCode] [int] NULL,
[StatusCode] [int] NULL,
[XmlData] [varchar] (max) COLLATE SQL_Latin1_General_CP1_CI_AS NULL
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO
ALTER TABLE [dbo].[XmlImportHistory] ADD CONSTRAINT [PK_XmlImportHistory] PRIMARY KEY CLUSTERED ([XmlImportHistoryID]) ON [PRIMARY]
GO
CREATE NONCLUSTERED INDEX [IX_XmlImportHistory_Orders] ON [dbo].[XmlImportHistory] ([OrderFID], [XmlImportHistoryID]) ON [PRIMARY]
GO
ALTER TABLE [dbo].[XmlImportHistory] ADD CONSTRAINT [FK_XmlImportHistory_Orders] FOREIGN KEY ([OrderFID]) REFERENCES [dbo].[Orders] ([PriKey])
GO
ALTER TABLE [dbo].[XmlImportHistory] ADD CONSTRAINT [FK_XmlImportHistory_XmlInterface] FOREIGN KEY ([XmlInterfaceFID]) REFERENCES [dbo].[XmlInterface] ([XmlInterfaceID])
GO
GRANT SELECT ON [dbo].[XmlImportHistory] TO [MssExec]
GRANT INSERT ON [dbo].[XmlImportHistory] TO [MssExec]
GRANT DELETE ON [dbo].[XmlImportHistory] TO [MssExec]
GRANT UPDATE ON [dbo].[XmlImportHistory] TO [MssExec]
GO