
/****** Object:  Table [dbo].[users]    Script Date: 02/17/2017 1:31:02 PM ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[users]') AND type in (N'U'))
DROP TABLE [dbo].[users]
GO
/****** Object:  Table [dbo].[unassigned]    Script Date: 02/17/2017 1:31:02 PM ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[unassigned]') AND type in (N'U'))
DROP TABLE [dbo].[unassigned]
GO
/****** Object:  Table [dbo].[stolens]    Script Date: 02/17/2017 1:31:02 PM ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[stolens]') AND type in (N'U'))
DROP TABLE [dbo].[stolens]
GO
/****** Object:  Table [dbo].[products_notes]    Script Date: 02/17/2017 1:31:02 PM ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[products_notes]') AND type in (N'U'))
DROP TABLE [dbo].[products_notes]
GO
/****** Object:  Table [dbo].[products]    Script Date: 02/17/2017 1:31:02 PM ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[products]') AND type in (N'U'))
DROP TABLE [dbo].[products]
GO
/****** Object:  Table [dbo].[product_descriptions]    Script Date: 02/17/2017 1:31:02 PM ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[product_descriptions]') AND type in (N'U'))
DROP TABLE [dbo].[product_descriptions]
GO
/****** Object:  Table [dbo].[masterkeys]    Script Date: 02/17/2017 1:31:02 PM ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[masterkeys]') AND type in (N'U'))
DROP TABLE [dbo].[masterkeys]
GO
/****** Object:  Table [dbo].[manufacturers]    Script Date: 02/17/2017 1:31:02 PM ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[manufacturers]') AND type in (N'U'))
DROP TABLE [dbo].[manufacturers]
GO
/****** Object:  Table [dbo].[losts]    Script Date: 02/17/2017 1:31:02 PM ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[losts]') AND type in (N'U'))
DROP TABLE [dbo].[losts]
GO
/****** Object:  Table [dbo].[keyways]    Script Date: 02/17/2017 1:31:02 PM ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[keyways]') AND type in (N'U'))
DROP TABLE [dbo].[keyways]
GO
/****** Object:  Table [dbo].[keyrings]    Script Date: 02/17/2017 1:31:02 PM ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[keyrings]') AND type in (N'U'))
DROP TABLE [dbo].[keyrings]
GO
/****** Object:  Table [dbo].[keyring_notes]    Script Date: 02/17/2017 1:31:02 PM ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[keyring_notes]') AND type in (N'U'))
DROP TABLE [dbo].[keyring_notes]
GO
/****** Object:  Table [dbo].[keymarks]    Script Date: 02/17/2017 1:31:02 PM ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[keymarks]') AND type in (N'U'))
DROP TABLE [dbo].[keymarks]
GO
/****** Object:  Table [dbo].[keymark_statuses]    Script Date: 02/17/2017 1:31:02 PM ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[keymark_statuses]') AND type in (N'U'))
DROP TABLE [dbo].[keymark_statuses]
GO
/****** Object:  Table [dbo].[keymark_sel]    Script Date: 02/17/2017 1:31:02 PM ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[keymark_sel]') AND type in (N'U'))
DROP TABLE [dbo].[keymark_sel]
GO
/****** Object:  Table [dbo].[hooks_notes]    Script Date: 02/17/2017 1:31:02 PM ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[hooks_notes]') AND type in (N'U'))
DROP TABLE [dbo].[hooks_notes]
GO
/****** Object:  Table [dbo].[hooks_deleted_notes]    Script Date: 02/17/2017 1:31:02 PM ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[hooks_deleted_notes]') AND type in (N'U'))
DROP TABLE [dbo].[hooks_deleted_notes]
GO
/****** Object:  Table [dbo].[hooks_deleted]    Script Date: 02/17/2017 1:31:02 PM ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[hooks_deleted]') AND type in (N'U'))
DROP TABLE [dbo].[hooks_deleted]
GO
/****** Object:  Table [dbo].[hooks]    Script Date: 02/17/2017 1:31:02 PM ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[hooks]') AND type in (N'U'))
DROP TABLE [dbo].[hooks]
GO
/****** Object:  Table [dbo].[histories]    Script Date: 02/17/2017 1:31:02 PM ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[histories]') AND type in (N'U'))
DROP TABLE [dbo].[histories]
GO
/****** Object:  Table [dbo].[facility_zones]    Script Date: 02/17/2017 1:31:02 PM ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[facility_zones]') AND type in (N'U'))
DROP TABLE [dbo].[facility_zones]
GO
/****** Object:  Table [dbo].[facility_users]    Script Date: 02/17/2017 1:31:02 PM ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[facility_users]') AND type in (N'U'))
DROP TABLE [dbo].[facility_users]
GO
/****** Object:  Table [dbo].[facility_user_notes]    Script Date: 02/17/2017 1:31:02 PM ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[facility_user_notes]') AND type in (N'U'))
DROP TABLE [dbo].[facility_user_notes]
GO
/****** Object:  Table [dbo].[facility_products]    Script Date: 02/17/2017 1:31:02 PM ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[facility_products]') AND type in (N'U'))
DROP TABLE [dbo].[facility_products]
GO
/****** Object:  Table [dbo].[facility_product_notes]    Script Date: 02/17/2017 1:31:02 PM ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[facility_product_notes]') AND type in (N'U'))
DROP TABLE [dbo].[facility_product_notes]
GO
/****** Object:  Table [dbo].[facility_Notes]    Script Date: 02/17/2017 1:31:02 PM ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[facility_Notes]') AND type in (N'U'))
DROP TABLE [dbo].[facility_Notes]
GO
/****** Object:  Table [dbo].[facility_master]    Script Date: 02/17/2017 1:31:02 PM ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[facility_master]') AND type in (N'U'))
DROP TABLE [dbo].[facility_master]
GO
/****** Object:  Table [dbo].[facility_description]    Script Date: 02/17/2017 1:31:02 PM ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[facility_description]') AND type in (N'U'))
DROP TABLE [dbo].[facility_description]
GO
/****** Object:  Table [dbo].[facility]    Script Date: 02/17/2017 1:31:02 PM ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[facility]') AND type in (N'U'))
DROP TABLE [dbo].[facility]
GO
/****** Object:  Table [dbo].[facilities]    Script Date: 02/17/2017 1:31:02 PM ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[facilities]') AND type in (N'U'))
DROP TABLE [dbo].[facilities]
GO
/****** Object:  Table [dbo].[employees_deleted]    Script Date: 02/17/2017 1:31:02 PM ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[employees_deleted]') AND type in (N'U'))
DROP TABLE [dbo].[employees_deleted]
GO
/****** Object:  Table [dbo].[employees]    Script Date: 02/17/2017 1:31:02 PM ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[employees]') AND type in (N'U'))
DROP TABLE [dbo].[employees]
GO
/****** Object:  Table [dbo].[employee_types]    Script Date: 02/17/2017 1:31:02 PM ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[employee_types]') AND type in (N'U'))
DROP TABLE [dbo].[employee_types]
GO
/****** Object:  Table [dbo].[employee_titles]    Script Date: 02/17/2017 1:31:02 PM ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[employee_titles]') AND type in (N'U'))
DROP TABLE [dbo].[employee_titles]
GO
/****** Object:  Table [dbo].[employee_notes]    Script Date: 02/17/2017 1:31:02 PM ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[employee_notes]') AND type in (N'U'))
DROP TABLE [dbo].[employee_notes]
GO
/****** Object:  Table [dbo].[doors_deleted]    Script Date: 02/17/2017 1:31:02 PM ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[doors_deleted]') AND type in (N'U'))
DROP TABLE [dbo].[doors_deleted]
GO
/****** Object:  Table [dbo].[doors]    Script Date: 02/17/2017 1:31:02 PM ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[doors]') AND type in (N'U'))
DROP TABLE [dbo].[doors]
GO
/****** Object:  Table [dbo].[door_types]    Script Date: 02/17/2017 1:31:02 PM ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[door_types]') AND type in (N'U'))
DROP TABLE [dbo].[door_types]
GO
/****** Object:  Table [dbo].[door_notes]    Script Date: 02/17/2017 1:31:02 PM ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[door_notes]') AND type in (N'U'))
DROP TABLE [dbo].[door_notes]
GO
/****** Object:  Table [dbo].[destroyeds]    Script Date: 02/17/2017 1:31:02 PM ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[destroyeds]') AND type in (N'U'))
DROP TABLE [dbo].[destroyeds]
GO
/****** Object:  Table [dbo].[departments]    Script Date: 02/17/2017 1:31:02 PM ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[departments]') AND type in (N'U'))
DROP TABLE [dbo].[departments]
GO
/****** Object:  Table [dbo].[department_notes]    Script Date: 02/17/2017 1:31:02 PM ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[department_notes]') AND type in (N'U'))
DROP TABLE [dbo].[department_notes]
GO
/****** Object:  Table [dbo].[cores]    Script Date: 02/17/2017 1:31:02 PM ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[cores]') AND type in (N'U'))
DROP TABLE [dbo].[cores]
GO
/****** Object:  Table [dbo].[coremarks]    Script Date: 02/17/2017 1:31:02 PM ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[coremarks]') AND type in (N'U'))
DROP TABLE [dbo].[coremarks]
GO
/****** Object:  Table [dbo].[core_notes]    Script Date: 02/17/2017 1:31:02 PM ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[core_notes]') AND type in (N'U'))
DROP TABLE [dbo].[core_notes]
GO
/****** Object:  Table [dbo].[control_sel]    Script Date: 02/17/2017 1:31:02 PM ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[control_sel]') AND type in (N'U'))
DROP TABLE [dbo].[control_sel]
GO
/****** Object:  Table [dbo].[control_key]    Script Date: 02/17/2017 1:31:02 PM ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[control_key]') AND type in (N'U'))
DROP TABLE [dbo].[control_key]
GO
/****** Object:  Table [dbo].[cabinets_notes]    Script Date: 02/17/2017 1:31:02 PM ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[cabinets_notes]') AND type in (N'U'))
DROP TABLE [dbo].[cabinets_notes]
GO
/****** Object:  Table [dbo].[cabinets]    Script Date: 02/17/2017 1:31:02 PM ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[cabinets]') AND type in (N'U'))
DROP TABLE [dbo].[cabinets]
GO
/****** Object:  Table [dbo].[buildings]    Script Date: 02/17/2017 1:31:02 PM ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[buildings]') AND type in (N'U'))
DROP TABLE [dbo].[buildings]
GO
/****** Object:  Table [dbo].[building_notes]    Script Date: 02/17/2017 1:31:02 PM ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[building_notes]') AND type in (N'U'))
DROP TABLE [dbo].[building_notes]
GO
/****** Object:  Table [dbo].[best_system]    Script Date: 02/17/2017 1:31:02 PM ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[best_system]') AND type in (N'U'))
DROP TABLE [dbo].[best_system]
GO
/****** Object:  Table [dbo].[best_locks]    Script Date: 02/17/2017 1:31:02 PM ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[best_locks]') AND type in (N'U'))
DROP TABLE [dbo].[best_locks]
GO
/****** Object:  Table [dbo].[best_key]    Script Date: 02/17/2017 1:31:02 PM ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[best_key]') AND type in (N'U'))
DROP TABLE [dbo].[best_key]
GO
/****** Object:  Table [dbo].[best_key]    Script Date: 02/17/2017 1:31:02 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[best_key]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[best_key](
	[FacilityID] [int] NULL,
	[ID] [int] NULL,
	[KeymarkID] [int] NULL,
	[KeyDispositonID] [int] NULL,
	[KeyProductID] [int] NULL,
	[DescriptionID] [int] NULL,
	[KeySerialNo] [varchar](50) NULL,
	[KeySerialize] [int] NULL,
	[KeyUID] [int] NULL,
	[KeyDispositionUID] [int] NULL,
	[KeyDispositionTypeID] [int] NULL,
	[KeyOosDate] [datetime] NULL,
	[KeyFinalDispUID] [int] NULL,
	[KeyFinalDispTypeID] [int] NULL
) ON [PRIMARY]
END
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[best_locks]    Script Date: 02/17/2017 1:31:02 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[best_locks]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[best_locks](
	[FacilityID] [int] NULL,
	[ID] [int] NULL,
	[DescriptionID] [int] NULL,
	[DispositionID] [int] NULL,
	[ProductID] [int] NULL,
	[LockSerialNo] [varchar](50) NULL,
	[LockSerialize] [int] NULL,
	[DispositionUID] [int] NULL,
	[DispositionTypeID] [int] NULL,
	[OosDate] [datetime] NULL
) ON [PRIMARY]
END
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[best_system]    Script Date: 02/17/2017 1:31:02 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[best_system]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[best_system](
	[FacilityID] [int] NULL,
	[ID] [int] NULL,
	[KeywayID] [int] NULL,
	[GmMasterKeyID] [int] NULL,
	[SystemName] [varchar](50) NULL,
	[SystemTypeIx] [int] NULL,
	[PinSizeIx] [int] NULL,
	[MarkIx] [int] NULL,
	[KeyStamp] [varchar](10) NULL
) ON [PRIMARY]
END
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[building_notes]    Script Date: 02/17/2017 1:31:02 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[building_notes]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[building_notes](
	[FacilityID] [int] NULL,
	[ID] [int] NULL,
	[Note] [varchar](max) NULL
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
END
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[buildings]    Script Date: 02/17/2017 1:31:02 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[buildings]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[buildings](
	[FacilityID] [int] NULL,
	[ID] [int] NULL,
	[FacilityZoneID] [int] NULL,
	[DescriptionID] [int] NULL,
	[BuildingName] [varchar](50) NULL
) ON [PRIMARY]
END
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[cabinets]    Script Date: 02/17/2017 1:31:02 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[cabinets]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[cabinets](
	[FacilityID] [int] NULL,
	[ID] [int] NULL,
	[DescriptionID] [int] NULL,
	[CabinetName] [varchar](30) NULL
) ON [PRIMARY]
END
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[cabinets_notes]    Script Date: 02/17/2017 1:31:02 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[cabinets_notes]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[cabinets_notes](
	[FacilityID] [int] NULL,
	[ID] [int] NULL,
	[Note] [varchar](max) NULL
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
END
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[control_key]    Script Date: 02/17/2017 1:31:02 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[control_key]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[control_key](
	[FacilityID] [int] NULL,
	[ID] [int] NULL,
	[ControlKeymarkID] [int] NULL,
	[SeriesKeymarkID] [int] NULL
) ON [PRIMARY]
END
GO
/****** Object:  Table [dbo].[control_sel]    Script Date: 02/17/2017 1:31:02 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[control_sel]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[control_sel](
	[FacilityID] [int] NULL,
	[ID] [int] NULL,
	[SelMasterCoreID] [int] NULL,
	[SelOperCoreID] [int] NULL
) ON [PRIMARY]
END
GO
/****** Object:  Table [dbo].[core_notes]    Script Date: 02/17/2017 1:31:02 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[core_notes]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[core_notes](
	[FacilityID] [int] NULL,
	[ID] [int] NULL,
	[Note] [varchar](max) NULL
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
END
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[coremarks]    Script Date: 02/17/2017 1:31:02 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[coremarks]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[coremarks](
	[FacilityID] [int] NULL,
	[ID] [int] NULL,
	[Coremark] [varchar](20) NULL,
	[KeymarkID] [int] NULL
) ON [PRIMARY]
END
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[cores]    Script Date: 02/17/2017 1:31:02 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[cores]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[cores](
	[FacilityID] [int] NULL,
	[ID] [int] NULL,
	[CoremarkID] [int] NULL,
	[DispositionID] [int] NULL,
	[ProductID] [int] NULL,
	[CoreSerialNo] [varchar](50) NULL,
	[CoreSerialize] [int] NULL,
	[CoreUID] [int] NULL,
	[CoreDispositionUID] [int] NULL,
	[CoreDispositionTypeID] [int] NULL,
	[CoreOosDate] [datetime] NULL,
	[CoreFinalDispUID] [int] NULL,
	[CoreFinalDispTypeID] [int] NULL
) ON [PRIMARY]
END
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[department_notes]    Script Date: 02/17/2017 1:31:02 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[department_notes]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[department_notes](
	[FacilityID] [int] NULL,
	[ID] [int] NULL,
	[Note] [varchar](max) NULL
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
END
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[departments]    Script Date: 02/17/2017 1:31:02 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[departments]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[departments](
	[FacilityID] [int] NULL,
	[ID] [int] NULL,
	[DepartmentName] [varchar](50) NULL,
	[DescriptionID] [int] NULL
) ON [PRIMARY]
END
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[destroyeds]    Script Date: 02/17/2017 1:31:02 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[destroyeds]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[destroyeds](
	[FacilityID] [int] NULL,
	[ID] [int] NULL,
	[DescriptionID] [int] NULL
) ON [PRIMARY]
END
GO
/****** Object:  Table [dbo].[door_notes]    Script Date: 02/17/2017 1:31:02 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[door_notes]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[door_notes](
	[FacilityID] [int] NULL,
	[ID] [int] NULL,
	[Note] [varchar](max) NULL
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
END
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[door_types]    Script Date: 02/17/2017 1:31:02 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[door_types]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[door_types](
	[FacilityID] [int] NULL,
	[ID] [int] NULL,
	[DoorTypeName] [varchar](50) NULL
) ON [PRIMARY]
END
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[doors]    Script Date: 02/17/2017 1:31:02 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[doors]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[doors](
	[FacilityID] [int] NULL,
	[ID] [int] NULL,
	[DescriptionID] [int] NULL,
	[DoorTypeID] [int] NULL,
	[DoorNumber] [varchar](50) NULL,
	[Area] [varchar](50) NULL,
	[DoorUID] [int] NULL,
	[BuildingID] [int] NULL
) ON [PRIMARY]
END
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[doors_deleted]    Script Date: 02/17/2017 1:31:02 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[doors_deleted]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[doors_deleted](
	[FacilityID] [int] NULL,
	[ID] [int] NULL,
	[DescriptionIDDel] [int] NULL,
	[DoorTypeIDDel] [int] NULL,
	[DoorNumberDel] [varchar](50) NULL,
	[AreaDel] [varchar](50) NULL,
	[DoorUIDDel] [int] NULL,
	[DoorDeletedDate] [datetime] NULL,
	[BuildingID] [int] NULL
) ON [PRIMARY]
END
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[employee_notes]    Script Date: 02/17/2017 1:31:02 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[employee_notes]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[employee_notes](
	[FacilityID] [int] NULL,
	[ID] [int] NULL,
	[Note] [varchar](max) NULL
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
END
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[employee_titles]    Script Date: 02/17/2017 1:31:02 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[employee_titles]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[employee_titles](
	[FacilityID] [int] NULL,
	[ID] [int] NULL,
	[EmployeeTitleName] [varchar](50) NULL
) ON [PRIMARY]
END
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[employee_types]    Script Date: 02/17/2017 1:31:02 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[employee_types]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[employee_types](
	[FacilityID] [int] NULL,
	[ID] [int] NULL,
	[EmployeeTypeName] [varchar](50) NULL
) ON [PRIMARY]
END
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[employees]    Script Date: 02/17/2017 1:31:02 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[employees]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[employees](
	[FacilityID] [int] NULL,
	[ID] [int] NULL,
	[EmployeeTypeID] [int] NULL,
	[EmployeeTitleID] [int] NULL,
	[DescriptionID] [int] NULL,
	[LastName] [varchar](50) NULL,
	[FirstName] [varchar](50) NULL,
	[MiddleInit] [varchar](2) NULL,
	[EmployeeID] [varchar](50) NULL,
	[DepartmentID] [int] NULL
) ON [PRIMARY]
END
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[employees_deleted]    Script Date: 02/17/2017 1:31:02 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[employees_deleted]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[employees_deleted](
	[FacilityID] [int] NULL,
	[ID] [int] NULL,
	[EmployeeTypeIDDel] [int] NULL,
	[EmployeeTitleIDDel] [int] NULL,
	[DescriptionIDDel] [int] NULL,
	[LastNameDel] [varchar](50) NULL,
	[FirstNameDel] [varchar](50) NULL,
	[MiddleInitDel] [varchar](2) NULL,
	[EmployeeIDDel] [varchar](50) NULL,
	[EmployeeUIDDel] [int] NULL,
	[EmployeeDeletedDate] [datetime] NULL,
	[DepartmentIDDel] [int] NULL
) ON [PRIMARY]
END
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[facilities]    Script Date: 02/17/2017 1:31:02 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[facilities]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[facilities](
	[ID] [int] NULL,
	[FacilityName] [varchar](50) NULL,
	[DatabasePath] [varchar](50) NULL
) ON [PRIMARY]
END
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[facility]    Script Date: 02/17/2017 1:31:02 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[facility]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[facility](
	[FacilityID] [int] NULL,
	[ID] [int] NULL,
	[Site_FacilityID] [int] NULL,
	[DescriptionID] [int] NULL,
	[BackupRetention] [int] NULL,
	[BackupFrequency] [int] NULL,
	[BuildingDefault] [int] NULL,
	[CabinetDefault] [int] NULL,
	[CoreDefault] [int] NULL,
	[CoremarkDefault] [int] NULL,
	[DepartmentDefault] [int] NULL,
	[DisplacedDefault] [int] NULL,
	[DoorDefault] [int] NULL,
	[EmployeeDefault] [int] NULL,
	[FacilityDefault] [int] NULL,
	[HookDefault] [int] NULL,
	[KeyDefault] [int] NULL,
	[KeymarkDefault] [int] NULL,
	[KeyringDefault] [int] NULL,
	[LockDefault] [int] NULL,
	[MasterkeyDefault] [int] NULL,
	[ProductDefault] [int] NULL,
	[ReportDefault] [int] NULL,
	[SiteDefault] [int] NULL,
	[UnassignedDefault] [int] NULL,
	[UserDefault] [int] NULL,
	[KeySerial] [int] NULL,
	[CoreSerial] [int] NULL,
	[LockSerial] [int] NULL
) ON [PRIMARY]
END
GO
/****** Object:  Table [dbo].[facility_description]    Script Date: 02/17/2017 1:31:02 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[facility_description]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[facility_description](
	[FacilityID] [int] NULL,
	[ID] [int] NULL,
	[Description] [varchar](30) NULL
) ON [PRIMARY]
END
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[facility_master]    Script Date: 02/17/2017 1:31:02 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[facility_master]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[facility_master](
	[ID] [int] IDENTITY(1,1) NOT NULL,
	[FacilityName] [varchar](100) NULL
) ON [PRIMARY]
END
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[facility_Notes]    Script Date: 02/17/2017 1:31:02 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[facility_Notes]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[facility_Notes](
	[FacilityID] [int] NULL,
	[ID] [int] NULL,
	[Note] [varchar](max) NULL
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
END
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[facility_product_notes]    Script Date: 02/17/2017 1:31:02 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[facility_product_notes]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[facility_product_notes](
	[FacilityID] [int] NULL,
	[ID] [int] NULL,
	[Note] [varchar](max) NULL
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
END
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[facility_products]    Script Date: 02/17/2017 1:31:02 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[facility_products]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[facility_products](
	[FacilityID] [int] NULL,
	[ID] [int] NULL,
	[ProductName] [varchar](50) NULL
) ON [PRIMARY]
END
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[facility_user_notes]    Script Date: 02/17/2017 1:31:02 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[facility_user_notes]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[facility_user_notes](
	[FacilityID] [int] NULL,
	[ID] [int] NULL,
	[Note] [varchar](max) NULL
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
END
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[facility_users]    Script Date: 02/17/2017 1:31:02 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[facility_users]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[facility_users](
	[FacilityID] [int] NULL,
	[ID] [int] NULL,
	[UserLogin] [varchar](50) NULL
) ON [PRIMARY]
END
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[facility_zones]    Script Date: 02/17/2017 1:31:02 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[facility_zones]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[facility_zones](
	[FacilityID] [int] NULL,
	[ID] [int] NULL,
	[FacilityZoneName] [varchar](30) NULL
) ON [PRIMARY]
END
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[histories]    Script Date: 02/17/2017 1:31:02 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[histories]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[histories](
	[FacilityID] [int] NULL,
	[ID] [int] NULL,
	[ItemID] [int] NULL,
	[ToID] [int] NULL,
	[UserID] [int] NULL,
	[DatetimeWhen] [datetime] NULL,
	[DateReturn] [datetime] NULL,
	[DateDue] [datetime] NULL,
	[Comment] [varchar](50) NULL,
	[ItemParentID] [int] NULL,
	[ItemParentType] [int] NULL,
	[ToParentID] [int] NULL,
	[ToParentType] [int] NULL
) ON [PRIMARY]
END
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[hooks]    Script Date: 02/17/2017 1:31:02 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[hooks]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[hooks](
	[FacilityID] [int] NULL,
	[ID] [int] NULL,
	[HookName] [varchar](30) NULL,
	[HookDescription] [varchar](30) NULL,
	[HookUID] [int] NULL,
	[CabinetID] [int] NULL
) ON [PRIMARY]
END
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[hooks_deleted]    Script Date: 02/17/2017 1:31:02 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[hooks_deleted]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[hooks_deleted](
	[FacilityID] [int] NULL,
	[ID] [int] NULL,
	[HookNameDel] [varchar](30) NULL,
	[HookDescriptionDel] [varchar](30) NULL,
	[HookUIDDel] [int] NULL,
	[HookDeletedDate] [datetime] NULL,
	[CabinetID] [int] NULL
) ON [PRIMARY]
END
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[hooks_deleted_notes]    Script Date: 02/17/2017 1:31:02 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[hooks_deleted_notes]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[hooks_deleted_notes](
	[FacilityID] [int] NULL,
	[ID] [int] NULL,
	[Note] [varchar](max) NULL
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
END
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[hooks_notes]    Script Date: 02/17/2017 1:31:02 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[hooks_notes]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[hooks_notes](
	[FacilityID] [int] NULL,
	[ID] [int] NULL,
	[Note] [varchar](max) NULL
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
END
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[keymark_sel]    Script Date: 02/17/2017 1:31:02 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[keymark_sel]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[keymark_sel](
	[FacilityID] [int] NULL,
	[ID] [int] NULL,
	[SelMasterKeyID] [int] NULL,
	[SelOperKeyIDID] [int] NULL
) ON [PRIMARY]
END
GO
/****** Object:  Table [dbo].[keymark_statuses]    Script Date: 02/17/2017 1:31:02 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[keymark_statuses]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[keymark_statuses](
	[FacilityID] [int] NULL,
	[ID] [int] NULL,
	[KeymarkStatusName] [varchar](30) NULL
) ON [PRIMARY]
END
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[keymarks]    Script Date: 02/17/2017 1:31:02 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[keymarks]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[keymarks](
	[FacilityID] [int] NULL,
	[ID] [int] NULL,
	[KeymarkStatusID] [int] NULL,
	[KeymarkSystemID] [int] NULL,
	[Keymark] [varchar](20) NULL,
	[Keycut] [varchar](10) NULL,
	[LevelIx] [int] NULL,
	[MasterkeyID] [int] NULL
) ON [PRIMARY]
END
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[keyring_notes]    Script Date: 02/17/2017 1:31:02 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[keyring_notes]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[keyring_notes](
	[FacilityID] [int] NULL,
	[ID] [int] NULL,
	[Note] [varchar](max) NULL
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
END
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[keyrings]    Script Date: 02/17/2017 1:31:02 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[keyrings]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[keyrings](
	[FacilityID] [int] NULL,
	[ID] [int] NULL,
	[DescriptionID] [int] NULL,
	[DispositionID] [int] NULL,
	[KeyringID] [varchar](50) NULL,
	[KeyringUID] [int] NULL,
	[DispostionUID] [int] NULL,
	[DispositionType] [int] NULL,
	[KeyringOosDate] [datetime] NULL
) ON [PRIMARY]
END
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[keyways]    Script Date: 02/17/2017 1:31:02 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[keyways]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[keyways](
	[FacilityID] [int] NULL,
	[ID] [int] NULL,
	[KeywayName] [varchar](10) NULL
) ON [PRIMARY]
END
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[losts]    Script Date: 02/17/2017 1:31:02 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[losts]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[losts](
	[FacilityID] [int] NULL,
	[ID] [int] NULL,
	[DescriptionID] [int] NULL
) ON [PRIMARY]
END
GO
/****** Object:  Table [dbo].[manufacturers]    Script Date: 02/17/2017 1:31:02 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[manufacturers]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[manufacturers](
	[ID] [int] NULL,
	[ManufacturerName] [varchar](50) NULL
) ON [PRIMARY]
END
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[masterkeys]    Script Date: 02/17/2017 1:31:02 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[masterkeys]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[masterkeys](
	[FacilityID] [int] NULL,
	[ID] [int] NULL,
	[BestSystemID] [int] NULL,
	[IsMasterID] [int] NULL
) ON [PRIMARY]
END
GO
/****** Object:  Table [dbo].[product_descriptions]    Script Date: 02/17/2017 1:31:02 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[product_descriptions]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[product_descriptions](
	[ID] [int] NULL,
	[Description] [varchar](50) NULL
) ON [PRIMARY]
END
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[products]    Script Date: 02/17/2017 1:31:02 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[products]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[products](
	[ID] [int] NULL,
	[ManufacturerID] [int] NULL,
	[DescriptionID] [int] NULL,
	[NumCores] [int] NULL,
	[ProductName] [varchar](50) NULL,
	[ProductTypeIX] [int] NULL
) ON [PRIMARY]
END
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[products_notes]    Script Date: 02/17/2017 1:31:02 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[products_notes]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[products_notes](
	[ID] [int] NULL,
	[Note] [varchar](max) NULL
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
END
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[stolens]    Script Date: 02/17/2017 1:31:02 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[stolens]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[stolens](
	[FacilityID] [int] NULL,
	[ID] [int] NULL,
	[DescriptionID] [int] NULL
) ON [PRIMARY]
END
GO
/****** Object:  Table [dbo].[unassigned]    Script Date: 02/17/2017 1:31:02 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[unassigned]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[unassigned](
	[FacilityID] [int] NULL,
	[ID] [int] NULL,
	[DescriptionID] [int] NULL
) ON [PRIMARY]
END
GO
/****** Object:  Table [dbo].[users]    Script Date: 02/17/2017 1:31:02 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[users]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[users](
	[ID] [int] NULL,
	[Privileges] [bigint] NULL,
	[ToolUse] [bigint] NULL,
	[DescriptionID] [int] NULL,
	[CurrentFacilityID] [int] NULL,
	[Login] [varchar](50) NULL,
	[Password] [varchar](50) NULL,
	[UseColor] [int] NULL,
	[PERMIT_BUILDING] [bit] NULL,
	[PERMIT_CABINET] [bit] NULL,
	[PERMIT_CORE] [bit] NULL,
	[PERMIT_COREMARK] [bit] NULL,
	[PERMIT_DEPT] [bit] NULL,
	[PERMIT_DISPLACED] [bit] NULL,
	[PERMIT_DOOR] [bit] NULL,
	[PERMIT_EMPLOYEE] [bit] NULL,
	[PERMIT_FACILITY] [bit] NULL,
	[PERMIT_HOOK] [bit] NULL,
	[PERMIT_KEY_CARD] [bit] NULL,
	[PERMIT_KEYMARK] [bit] NULL,
	[PERMIT_KEYRING] [bit] NULL,
	[PERMIT_LOCK] [bit] NULL,
	[PERMIT_MASTERKEY] [bit] NULL,
	[PERMIT_PRODUCT] [bit] NULL,
	[PERMIT_REPORTS] [bit] NULL,
	[PERMIT_SITE] [bit] NULL,
	[PERMIT_UNASSIGNED] [bit] NULL,
	[PERMIT_USER] [bit] NULL,
	[PERMIT_SUPER_USER] [bit] NULL,
	[PERMIT_VIEW_CODES] [bit] NULL,
	[PERMIT_UPDATE] [bit] NULL,
	[PERMIT_TRANSACTIONS] [bit] NULL,
	[PERMIT_PIN_CALC] [bit] NULL,
	[PERMIT_VIEW_MASTER_CODES] [bit] NULL,
	[PERMIT_UPDATE_SOME] [bit] NULL,
	[PERMIT_TRANSACTIONS_SOME] [bit] NULL,
	[PERMIT_TRANS_RPT] [bit] NULL,
	[PERMIT_UPDATE_BUILDING] [bit] NULL,
	[PERMIT_UPDATE_CABINET] [bit] NULL,
	[PERMIT_UPDATE_CORE] [bit] NULL,
	[PERMIT_UPDATE_COREMARK] [bit] NULL,
	[PERMIT_UPDATE_DEPT] [bit] NULL,
	[PERMIT_UPDATE_DISPLACED] [bit] NULL,
	[PERMIT_UPDATE_DOOR] [bit] NULL,
	[PERMIT_UPDATE_EMPLOYEE] [bit] NULL,
	[PERMIT_UPDATE_FACILITY] [bit] NULL,
	[PERMIT_UPDATE_HOOK] [bit] NULL,
	[PERMIT_UPDATE_KEY] [bit] NULL,
	[PERMIT_UPDATE_KEYMARK] [bit] NULL,
	[PERMIT_UPDATE_KEYRING] [bit] NULL,
	[PERMIT_UPDATE_LOCK] [bit] NULL,
	[PERMIT_UPDATE_MASTERKEY] [bit] NULL,
	[PERMIT_UPDATE_PRODUCT] [bit] NULL,
	[PERMIT_UPDATE_REPORTS] [bit] NULL,
	[PERMIT_UPDATE_SITE] [bit] NULL,
	[PERMIT_UPDATE_UNASSIGNED] [bit] NULL,
	[PERMIT_UPDATE_USER] [bit] NULL,
	[PERMIT_TRANS_BUILDING] [bit] NULL,
	[PERMIT_TRANS_CABINET] [bit] NULL,
	[PERMIT_TRANS_CORE] [bit] NULL,
	[PERMIT_TRANS_COREMARK] [bit] NULL,
	[PERMIT_TRANS_DEPT] [bit] NULL,
	[PERMIT_TRANS_DISPLACED] [bit] NULL,
	[PERMIT_TRANS_DOOR] [bit] NULL,
	[PERMIT_TRANS_EMPLOYEE] [bit] NULL,
	[PERMIT_TRANS_FACILITY] [bit] NULL,
	[PERMIT_TRANS_HOOK] [bit] NULL,
	[PERMIT_TRANS_KEY] [bit] NULL,
	[PERMIT_TRANS_KEYMARK] [bit] NULL,
	[PERMIT_TRANS_KEYRING] [bit] NULL,
	[PERMIT_TRANS_LOCK] [bit] NULL,
	[PERMIT_TRANS_MASTERKEY] [bit] NULL,
	[PERMIT_TRANS_PRODUCT] [bit] NULL,
	[PERMIT_TRANS_REPORTS] [bit] NULL,
	[PERMIT_TRANS_SITE] [bit] NULL,
	[PERMIT_TRANS_UNASSIGNED] [bit] NULL,
	[PERMIT_TRANS_USER] [bit] NULL
) ON [PRIMARY]
END
GO
SET ANSI_PADDING OFF
GO
