IF EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_ArrangementReservationConferenceLineXtab_ArrangementLines]') AND parent_object_id = OBJECT_ID(N'[dbo].[ArrangementReservationConferenceLineXtab]'))
BEGIN
  ALTER TABLE dbo.ArrangementReservationConferenceLineXtab
  	DROP CONSTRAINT FK_ArrangementReservationConferenceLineXtab_ArrangementLines
END

IF EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_ArrangementReservationConferenceLineXtab_RESERVATIONCONFERENCELINE]') AND parent_object_id = OBJECT_ID(N'[dbo].[ArrangementReservationConferenceLineXtab]'))
BEGIN
  ALTER TABLE dbo.ArrangementReservationConferenceLineXtab
  	DROP CONSTRAINT FK_ArrangementReservationConferenceLineXtab_RESERVATIONCONFERENCELINE
END

IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_ArrangementReservationConferenceLineXtab_ArrangementLines2]') AND parent_object_id = OBJECT_ID(N'[dbo].[ArrangementReservationConferenceLineXtab]'))
BEGIN
  ALTER TABLE [dbo].[ArrangementReservationConferenceLineXtab]  WITH NOCHECK ADD  CONSTRAINT [FK_ArrangementReservationConferenceLineXtab_ArrangementLines2] FOREIGN KEY([ArrangementLineNumber])
  REFERENCES [dbo].[ArrangementLines] ([ArrangementLineNumber])
  ON UPDATE CASCADE
  ON DELETE CASCADE
  
  ALTER TABLE [dbo].[ArrangementReservationConferenceLineXtab] CHECK CONSTRAINT [FK_ArrangementReservationConferenceLineXtab_ArrangementLines2]
END

IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_ArrangementReservationConferenceLineXtab_RESERVATIONCONFERENCELINE2]') AND parent_object_id = OBJECT_ID(N'[dbo].[ArrangementReservationConferenceLineXtab]'))
BEGIN
  ALTER TABLE [dbo].[ArrangementReservationConferenceLineXtab]  WITH NOCHECK ADD  CONSTRAINT [FK_ArrangementReservationConferenceLineXtab_RESERVATIONCONFERENCELINE2] FOREIGN KEY([ReservationConfLineNumber])
  REFERENCES [dbo].[ReservationConferenceLine] ([ReservationConfLineNumber])
  ON UPDATE CASCADE
  ON DELETE CASCADE

  ALTER TABLE [dbo].[ArrangementReservationConferenceLineXtab] CHECK CONSTRAINT [FK_ArrangementReservationConferenceLineXtab_RESERVATIONCONFERENCELINE2]
END
