IF OBJECT_ID(N'dbo._TabVyroba_OdpadPekarna', N'U') IS NULL
 CREATE TABLE dbo._TabVyroba_OdpadPekarna (
  ID int IDENTITY(1, 1) NOT NULL, IDStroje int NOT NULL, Datum datetime NOT NULL, Smena tinyint NOT NULL, OdpadSuchy numeric(19, 6) DEFAULT 0 NOT NULL,
  OdpadMokry numeric(19, 6) DEFAULT 0 NOT NULL, Poznamka nvarchar(500) COLLATE Czech_CI_AS NULL, Datum_X AS CONVERT([datetime],CONVERT([int],CONVERT([float],[Datum]))),
  Datum_D AS datepart(day,[Datum]), Datum_W AS datepart(week,[Datum]), Datum_M AS datepart(month,[Datum]), Datum_Q AS datepart(quarter,[Datum]), Datum_Y AS datepart(year,[Datum]),
  Autor nvarchar(80) COLLATE Czech_CI_AS DEFAULT suser_sname() NOT NULL,
  DatPorizeni datetime DEFAULT getdate() NOT NULL,
  Zmenil nvarchar(80) COLLATE Czech_CI_AS NULL,
  DatZmeny datetime NULL,
  CONSTRAINT PK_TabVyroba_OdpadPekarna 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_OdpadPekarna') AND name=N'EI_TabVyroba_OdpadPekarna_Stroj')
 CREATE NONCLUSTERED INDEX EI_TabVyroba_OdpadPekarna_Stroj ON dbo._TabVyroba_OdpadPekarna (IDStroje)
  WITH ( PAD_INDEX = OFF, DROP_EXISTING = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON)
