
IF EXISTS (SELECT 1 FROM sys.indexes WHERE name = 'LD0I0H' AND object_id = OBJECT_ID('LD0P0H'))
   DROP INDEX LD0I0H ON LD0P0H
GO

IF EXISTS (SELECT 1 FROM sys.indexes WHERE name = 'LD0C1H' AND object_id = OBJECT_ID('LD0P0H'))
   DROP INDEX LD0C1H ON LD0P0H
GO

ALTER TABLE LD0P0H SET (SYSTEM_VERSIONING=OFF)
GO
IF EXISTS (SELECT 1 FROM sys.key_constraints WHERE name = 'PK_LD0P0H' AND parent_object_id = OBJECT_ID('LD0P0H'))
   ALTER TABLE LD0P0H DROP CONSTRAINT PK_LD0P0H
GO

IF NOT EXISTS (SELECT 1 FROM sys.key_constraints WHERE name = 'PK_LD0P0H' AND parent_object_id = OBJECT_ID('LD0P0H'))
   ALTER TABLE LD0P0H ADD CONSTRAINT PK_LD0P0H PRIMARY KEY CLUSTERED (AKTUALNR)
GO

ALTER TABLE LD0P0H SET (SYSTEM_VERSIONING=ON)
GO

IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = 'LD0I1H' AND object_id = OBJECT_ID('LD0P0H'))
   CREATE INDEX LD0I1H ON LD0P0H(PNR)
GO