﻿IF EXISTS (SELECT 1
           FROM T_DICTIONARYITEMBASE
           WHERE ID = 6763
             AND TOROLT = 'F'
             AND C_TYPE = 'RendszerBeallitasTipus')
  AND EXISTS (SELECT 1
           FROM T_DICTIONARYITEMBASE
           WHERE ID = 6764
             AND TOROLT = 'F'
             AND C_TYPE = 'RendszerBeallitasTipus')
  AND EXISTS (SELECT 1
           FROM T_DICTIONARYITEMBASE
           WHERE ID = 6765
             AND TOROLT = 'F'
             AND C_TYPE = 'RendszerBeallitasTipus')
BEGIN
  ALTER TABLE T_RENDSZERBEALLITASTIPUS NOCHECK CONSTRAINT ALL
  ALTER TABLE T_RENDSZERBEALLITAS NOCHECK CONSTRAINT ALL
  ALTER TABLE T_MUNKAIDOKEDVEZMENYOKA NOCHECK CONSTRAINT ALL

  DELETE
  FROM T_DICTIONARYITEMBASE
  WHERE C_TYPE = 'RendszerBeallitasTipus'
    AND ID IN (6763, 6764 ,6765)

  DELETE
  FROM T_RENDSZERBEALLITASTIPUS
  WHERE ID IN (6763, 6764 ,6765)
  
  DELETE
  FROM T_RENDSZERBEALLITAS
  WHERE C_BEALLITASTIPUS IN (6763, 6764 ,6765)

  ALTER TABLE T_MUNKAIDOKEDVEZMENYOKA NOCHECK CONSTRAINT ALL
  ALTER TABLE T_RENDSZERBEALLITAS WITH CHECK CHECK CONSTRAINT ALL
  ALTER TABLE T_RENDSZERBEALLITASTIPUS WITH CHECK CHECK CONSTRAINT ALL
END
GO
