IF OBJECT_ID(N'dbo._TabVyroba_Vzorky', N'U') IS NULL
 CREATE TABLE dbo._TabVyroba_Vzorky (
  ID int IDENTITY(1, 1) NOT NULL,
  IDArchiv int NOT NULL,
  IDStroj int NOT NULL,
  IDKmenZbozi int NOT NULL,
  CisloZamMistr int NULL,
  KArchivaci bit DEFAULT 0 NULL,
  Ukonceno bit DEFAULT 0 NULL,
  Vyrazeno bit DEFAULT 0 NULL,
  Autor nvarchar(128) COLLATE Czech_CI_AS DEFAULT suser_sname() NOT 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_Q AS datepart(quarter,[DatPorizeni]),
  DatPorizeni_T AS datepart(week,[DatPorizeni]),
  DatPorizeni_Y AS datepart(year,[DatPorizeni]),
  CONSTRAINT PK__TabVyroba_Vzorky 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_Vzorky') AND name=N'EI__TabVyroba_Vzorky_Archiv')
 CREATE NONCLUSTERED INDEX EI__TabVyroba_Vzorky_Archiv ON dbo._TabVyroba_Vzorky (IDArchiv)
  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 OBJECT_ID(N'dbo._TabVyroba_VzorkyArchiv', N'U') IS NULL
 CREATE TABLE dbo._TabVyroba_VzorkyArchiv (
  ID int IDENTITY(1, 1) NOT NULL,
  Archiv nvarchar(50) COLLATE Czech_CI_AS DEFAULT N'' NOT NULL,
  Autor nvarchar(128) COLLATE Czech_CI_AS DEFAULT suser_sname() NOT 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_Q AS datepart(quarter,[DatPorizeni]),
  DatPorizeni_T AS datepart(week,[DatPorizeni]),
  DatPorizeni_Y AS datepart(year,[DatPorizeni]),
  DatUkonceni datetime NULL,
  DatUkonceni_X AS CONVERT([datetime],CONVERT([int],CONVERT([float],[DatUkonceni]))),
  DatUkonceni_D AS datepart(day,[DatUkonceni]),
  DatUkonceni_M AS datepart(month,[DatUkonceni]),
  DatUkonceni_T AS datepart(week,[DatUkonceni]),
  DatUkonceni_Y AS datepart(year,[DatUkonceni]),
  DatUkonceni_Q AS datepart(quarter,[DatUkonceni]),
  CONSTRAINT PK__TabVyroba_VzorkyArchiv PRIMARY KEY CLUSTERED (ID DESC) WITH ( PAD_INDEX = OFF, IGNORE_DUP_KEY = OFF, STATISTICS_NORECOMPUTE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON)
)

