IF OBJECT_ID(N'dbo._TabVyroba_KontrolyCCP1', N'U') IS NULL
 CREATE TABLE dbo._TabVyroba_KontrolyCCP1 (
  ID int IDENTITY(1, 1) NOT NULL,
  IDStroj int NULL,
  Smena tinyint NULL,
  Teplota numeric(8, 2) NULL,
  Rychlost numeric(15, 2) NULL,
  Hmotnost numeric(19, 6) NULL,
  Delka numeric(19, 6) NULL,
  Prumer numeric(19, 6) NULL,
  OdpovidaPredpisu bit DEFAULT 0 NULL,
  IDKmenZbozi int NOT NULL,
  NapravneOpatreni nvarchar(255) COLLATE Czech_CI_AS NULL,
  Uzavreno bit DEFAULT 0 NULL,
  Autor nvarchar(100) COLLATE Czech_CI_AS DEFAULT suser_sname() NOT NULL,
  Zmenil nvarchar(100) COLLATE Czech_CI_AS NULL,
  DatPorizeni datetime DEFAULT getdate() NOT NULL,
  DatPorizeni_X AS CONVERT([datetime],CONVERT([int],CONVERT([float],[DatPorizeni]))),
  DatPorizeni_D AS datepart(day,[DatPorizeni]),
  DatPorizeni_M AS datepart(month,[DatPorizeni]),
  DatPorizeni_Y AS datepart(year,[DatPorizeni]),
  DatPorizeni_W AS datepart(week,[DatPorizeni]),
  DatZmeny datetime NULL,
  VyrobniDen date NULL,
  CONSTRAINT PK__TabVyroba_KontrolyCCP1 PRIMARY KEY CLUSTERED (ID DESC) WITH (PAD_INDEX = OFF, IGNORE_DUP_KEY = OFF, STATISTICS_NORECOMPUTE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON)
 )



IF NOT EXISTS(SELECT 1 FROM sys.indexes WHERE object_id=OBJECT_ID('dbo._TabVyroba_KontrolyCCP1') AND name=N'EI__TabVyroba_KontrolyCCP1_Kmen')
 CREATE NONCLUSTERED INDEX EI__TabVyroba_KontrolyCCP1_Kmen ON dbo._TabVyroba_KontrolyCCP1 (IDKmenZbozi)
  WITH ( PAD_INDEX = OFF, DROP_EXISTING = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON)


IF NOT EXISTS(SELECT 1 FROM sys.indexes WHERE object_id=OBJECT_ID('dbo._TabVyroba_KontrolyCCP1') AND name=N'EI__TabVyroba_KontrolyCCP1_Stroj')
 CREATE NONCLUSTERED INDEX EI__TabVyroba_KontrolyCCP1_Stroj ON dbo._TabVyroba_KontrolyCCP1 (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)

