IF OBJECT_ID(N'dbo._TabVyroba_PaletyUkonceni', N'U') IS NULL
 CREATE TABLE dbo._TabVyroba_PaletyUkonceni (
  ID int IDENTITY(1, 1) NOT NULL,
  IDPalety INT,
  IDPrikaz INT,
  IDMzda INT,
  IDMezd NVARCHAR(max) NULL,
  PocetKs NUMERIC(19,6) DEFAULT 0.0 NOT NULL,
  PocetKA NUMERIC(19,6) DEFAULT 0.0 NOT NULL,
  NeuplnaPalPocetKA NUMERIC(19,6) DEFAULT 0.0 NOT NULL,
  NeuplnaPalKsVPoslKA NUMERIC(19,6) DEFAULT 0.0 NOT NULL,
  ErrMsg NVARCHAR(255) NULL,
  Autor nvarchar(80) DEFAULT suser_sname() NOT NULL,
  DatPorizeni datetime DEFAULT getdate() NOT NULL,
  PRIMARY KEY (ID DESC)
 )


/* 20.3.2024 */
IF COL_LENGTH(N'dbo._TabVyroba_PaletyUkonceni', N'IDPrikaz') IS NULL ALTER TABLE dbo._TabVyroba_PaletyUkonceni ADD IDPrikaz INT NULL
IF COL_LENGTH(N'dbo._TabVyroba_PaletyUkonceni', N'IDMzda') IS NULL ALTER TABLE dbo._TabVyroba_PaletyUkonceni ADD IDMzda INT NULL



DROP INDEX IF EXISTS EI__TabVyroba_PaletyUkonceni_IDPalety ON dbo._TabVyroba_PaletyUkonceni
 CREATE NONCLUSTERED INDEX EI__TabVyroba_PaletyUkonceni_IDPalety ON dbo._TabVyroba_PaletyUkonceni (IDPalety)
  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_PaletyUkonceni_IDPrikaz ON dbo._TabVyroba_PaletyUkonceni
 CREATE NONCLUSTERED INDEX EI__TabVyroba_PaletyUkonceni_IDPrikaz ON dbo._TabVyroba_PaletyUkonceni (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)

/* 8.10.2024 */
IF COL_LENGTH(N'dbo._TabVyroba_PaletyUkonceni', N'IDMezd') IS NULL ALTER TABLE dbo._TabVyroba_PaletyUkonceni ADD IDMezd NVARCHAR(MAX) NULL

/* 10.12.2024 */
IF COL_LENGTH(N'dbo._TabVyroba_PaletyUkonceni', N'ErrMsg') IS NULL ALTER TABLE dbo._TabVyroba_PaletyUkonceni ADD ErrMsg NVARCHAR(255) NULL
