CREATE TABLE [dbo].[DataSyncERPAccountIssues]
(
[ID] [int] NOT NULL IDENTITY(1, 1),
[DataSyncID] [int] NOT NULL,
[DataSyncERPAccountID] [int] NOT NULL,
[DataSyncDefERPAccountID] [int] NOT NULL,
[IssueType] [tinyint] NOT NULL,
[IssueData] [xml] NULL,
[IssueStatus] [tinyint] NOT NULL
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[DataSyncERPAccountIssues] ADD CONSTRAINT [PK_DataSyncERPAccountIssues_ID] PRIMARY KEY CLUSTERED ([ID]) ON [PRIMARY]
GO
ALTER TABLE [dbo].[DataSyncERPAccountIssues] ADD CONSTRAINT [FK_DataSyncERPAccountIssues_DataSyncDefERPAccountID_DataSyncDefERPAccount_ID] FOREIGN KEY ([DataSyncDefERPAccountID]) REFERENCES [dbo].[DataSyncDefERPAccount] ([ID])
GO
ALTER TABLE [dbo].[DataSyncERPAccountIssues] ADD CONSTRAINT [FK_DataSyncERPAccountIssues_DataSyncERPAccountID_DataSyncERPAccount_ID] FOREIGN KEY ([DataSyncERPAccountID]) REFERENCES [dbo].[DataSyncERPAccount] ([ID]) ON DELETE CASCADE
GO
ALTER TABLE [dbo].[DataSyncERPAccountIssues] ADD CONSTRAINT [FK_DataSyncERPAccountIssues_DataSyncID_DataSync_ID] FOREIGN KEY ([DataSyncID]) REFERENCES [dbo].[DataSync] ([ID])
GO