IF OBJECT_ID(N'dbo._TabVyroba_TestoSpotreba', N'U') IS NULL
 CREATE TABLE dbo._TabVyroba_TestoSpotreba (
  ID int IDENTITY(1, 1) NOT NULL,
  IDHlava int NULL,
  IDPrikaz int NULL,
  IDPrPostup INT,
  IDDoklad int NULL,
  Mnozstvi numeric(19, 6) DEFAULT 0.0 NOT NULL,
  DokladPrP int NULL,
  AltPrP nchar(1) COLLATE Czech_CI_AS NULL,
  PaletovyList nvarchar(50) NULL,
  Sarze nvarchar(30) NULL,
  DeviceID nvarchar(50) COLLATE Czech_CI_AS NULL,
  DatPorizeni datetime DEFAULT getdate() NOT NULL,
  CONSTRAINT PK__TabVyroba_TestoSpotreba PRIMARY KEY CLUSTERED (ID DESC) WITH ( PAD_INDEX = OFF, IGNORE_DUP_KEY = OFF, STATISTICS_NORECOMPUTE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON)
 )



/* 20.3.2024 */
IF COL_LENGTH(N'dbo._TabVyroba_TestoSpotreba', N'IDHlava') IS NOT NULL ALTER TABLE dbo._TabVyroba_TestoSpotreba ALTER COLUMN IDHlava INT NULL
IF COL_LENGTH(N'dbo._TabVyroba_TestoSpotreba', N'IDPrikaz') IS NOT NULL ALTER TABLE dbo._TabVyroba_TestoSpotreba ALTER COLUMN IDPrikaz INT NULL
IF COL_LENGTH(N'dbo._TabVyroba_TestoSpotreba', N'IDPrikaz') IS NULL ALTER TABLE dbo._TabVyroba_TestoSpotreba ADD IDPrikaz INT NULL
IF COL_LENGTH(N'dbo._TabVyroba_TestoSpotreba', N'IDPrPostup') IS NULL ALTER TABLE dbo._TabVyroba_TestoSpotreba ADD IDPrPostup INT NULL
IF COL_LENGTH(N'dbo._TabVyroba_TestoSpotreba', N'IDDoklad') IS NULL ALTER TABLE dbo._TabVyroba_TestoSpotreba ADD IDDoklad INT NULL


DROP INDEX IF EXISTS EI_TabVyroba_TestoSpotreba_IDHlava ON dbo._TabVyroba_TestoSpotreba
 CREATE NONCLUSTERED INDEX EI_TabVyroba_TestoSpotreba_IDHlava ON dbo._TabVyroba_TestoSpotreba (IDHlava)
  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_TestoSpotreba_IDPrikaz ON dbo._TabVyroba_TestoSpotreba
 CREATE NONCLUSTERED INDEX EI_TabVyroba_TestoSpotreba_IDPrikaz ON dbo._TabVyroba_TestoSpotreba (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_TestoSpotreba_IDPrPostup ON dbo._TabVyroba_TestoSpotreba
 CREATE NONCLUSTERED INDEX EI_TabVyroba_TestoSpotreba_IDPrPostup ON dbo._TabVyroba_TestoSpotreba (IDPrPostup)
  WITH ( PAD_INDEX = OFF, DROP_EXISTING = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON)
