IF OBJECT_ID(N'dbo._TabVyroba_OperaceStartStop', N'U') IS NULL
 CREATE TABLE dbo._TabVyroba_OperaceStartStop (
  ID int IDENTITY(1, 1) NOT NULL,
  IDPrijataDataJson int NOT NULL,
  IdPHIdent bigint NULL,
  IdPHIdent2 bigint NULL,
  IDPrikaz int NULL,
  Nazev NVARCHAR(50) NULL,
  DokladPrP int NULL,
  AltPrP nchar(1) COLLATE Czech_CI_AS NULL,
  SkupZbo nvarchar(3) COLLATE Czech_CI_AS NULL,
  RegCis nvarchar(30) COLLATE Czech_CI_AS NULL,
  IDKmenZbozi int NULL,
  IDStroj int NULL,
  IDPracoviste int NULL,
  CasStart datetime NULL,
  CasKonec datetime NULL,
  IDDokladOZ INT NULL,
  CONSTRAINT PK___TabVyrobaOperaceStartStop PRIMARY KEY CLUSTERED (ID DESC)
    WITH (PAD_INDEX = OFF, IGNORE_DUP_KEY = OFF, STATISTICS_NORECOMPUTE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON)
)


DROP INDEX IF EXISTS EI_TabVyroba_OperaceStartStop_IdPrijataDataJson ON dbo._TabVyroba_OperaceStartStop
 CREATE NONCLUSTERED INDEX EI_TabVyroba_OperaceStartStop_IdPrijataDataJson ON dbo._TabVyroba_OperaceStartStop (IDPrijataDataJson)
  WITH (PAD_INDEX = OFF, DROP_EXISTING = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON)

DROP INDEX IF EXISTS EI_TabVyroba_OperaceStartStop_Prikaz ON dbo._TabVyroba_OperaceStartStop
 CREATE NONCLUSTERED INDEX EI_TabVyroba_OperaceStartStop_Prikaz ON dbo._TabVyroba_OperaceStartStop (IDPrikaz)
  WITH (PAD_INDEX = OFF, DROP_EXISTING = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON)

DROP INDEX IF EXISTS EI_TabVyroba_OperaceStartStop_Stroj ON dbo._TabVyroba_OperaceStartStop
 CREATE NONCLUSTERED INDEX EI_TabVyroba_OperaceStartStop_Stroj ON dbo._TabVyroba_OperaceStartStop (IDStroj)
  WITH (PAD_INDEX = OFF, DROP_EXISTING = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON)



/* 26.10.2023 */
IF COL_LENGTH(N'dbo._TabVyroba_OperaceStartStop', N'PosledniChyba') IS NULL ALTER TABLE dbo._TabVyroba_OperaceStartStop ADD PosledniChyba NVARCHAR(255) NULL


/* 28.10.2023 */
IF COL_LENGTH(N'dbo._TabVyroba_OperaceStartStop', N'IDMzda') IS NULL ALTER TABLE dbo._TabVyroba_OperaceStartStop ADD IDMzda INT NULL
IF COL_LENGTH(N'dbo._TabVyroba_OperaceStartStop', N'IDEvidRozpracOper') IS NULL ALTER TABLE dbo._TabVyroba_OperaceStartStop ADD IDEvidRozpracOper INT NULL
IF COL_LENGTH(N'dbo._TabVyroba_OperaceStartStop', N'Ukonceno') IS NULL ALTER TABLE dbo._TabVyroba_OperaceStartStop ADD Ukonceno BIT NOT NULL DEFAULT 0

/* 13.10.2023 */
IF COL_LENGTH(N'dbo._TabVyroba_OperaceStartStop', N'IDDokladOZ') IS NULL ALTER TABLE dbo._TabVyroba_OperaceStartStop ADD IDDokladOZ INT NULL

/* 7.10.2024 */
IF COL_LENGTH(N'dbo._TabVyroba_OperaceStartStop', N'Nazev') IS NULL ALTER TABLE dbo._TabVyroba_OperaceStartStop ADD Nazev NVARCHAR(50) NULL

