-- DROP SCHEMA dbo;

-- CREATE SCHEMA dbo;
-- db_name.dbo.APP_Config_ definition

-- Drop table

-- DROP TABLE db_name.dbo.APP_Config_;

CREATE TABLE db_name.dbo.APP_Config_ (
	ID int IDENTITY(1,1) NOT NULL,
	Module_ID nvarchar(32) COLLATE Latin1_General_CI_AS NULL,
	[Key] nvarchar(32) COLLATE Latin1_General_CI_AS NULL,
	ValueI int NULL,
	ValueF float NULL,
	[ValueS] text COLLATE Latin1_General_CI_AS NULL,
	CONSTRAINT PK_APP_Config_ PRIMARY KEY (ID)
);
 CREATE NONCLUSTERED INDEX ix_AppCfg_module ON db_name.dbo.APP_Config_ (  Module_ID ASC  )  
	 WITH (  PAD_INDEX = OFF ,FILLFACTOR = 100  ,SORT_IN_TEMPDB = OFF , IGNORE_DUP_KEY = OFF , STATISTICS_NORECOMPUTE = OFF , ONLINE = OFF , ALLOW_ROW_LOCKS = ON , ALLOW_PAGE_LOCKS = ON  )
	 ON [PRIMARY ] ;


-- db_name.dbo.GPD_Abweichungen definition

-- Drop table

-- DROP TABLE db_name.dbo.GPD_Abweichungen;

CREATE TABLE db_name.dbo.GPD_Abweichungen (
	MSID int NOT NULL,
	RECID int NOT NULL,
	AW_Bis float NULL,
	AW_Neigung float NULL,
	AW_Azimut float NULL,
	AW_XW float NULL,
	AW_YW float NULL,
	AW_ZW float NULL,
	AW_Datum smalldatetime NULL,
	CONSTRAINT GPD_Abweichungen_PK PRIMARY KEY (MSID,RECID)
);


-- db_name.dbo.GPD_PLFirma definition

-- Drop table

-- DROP TABLE db_name.dbo.GPD_PLFirma;

CREATE TABLE db_name.dbo.GPD_PLFirma (
	PLF_ID int NOT NULL,
	PLF_ListID int NULL,
	PLF_Name1 nvarchar(64) COLLATE Latin1_General_CI_AS NULL,
	PLF_Name2 nvarchar(64) COLLATE Latin1_General_CI_AS NULL,
	PLF_PLZ nvarchar(10) COLLATE Latin1_General_CI_AS NULL,
	PLF_Ort nvarchar(64) COLLATE Latin1_General_CI_AS NULL,
	PLF_Strasse nvarchar(64) COLLATE Latin1_General_CI_AS NULL,
	PLF_Telefon1 nvarchar(64) COLLATE Latin1_General_CI_AS NULL,
	PLF_Telefon2 nvarchar(64) COLLATE Latin1_General_CI_AS NULL,
	PLF_Fax1 nvarchar(64) COLLATE Latin1_General_CI_AS NULL,
	PLF_FAx2 nvarchar(64) COLLATE Latin1_General_CI_AS NULL,
	PLF_Email1 nvarchar(64) COLLATE Latin1_General_CI_AS NULL,
	PLF_EMail2 nvarchar(64) COLLATE Latin1_General_CI_AS NULL,
	PLF_Typ int NULL,
	PLF_Land int NULL,
	PLF_WWW nvarchar(255) COLLATE Latin1_General_CI_AS NULL,
	PLF_Bemerkung nvarchar(255) COLLATE Latin1_General_CI_AS NULL,
	CONSTRAINT GPD_PLFirma_PK PRIMARY KEY (PLF_ID)
);


-- db_name.dbo.GPD_PLPerson definition

-- Drop table

-- DROP TABLE db_name.dbo.GPD_PLPerson;

CREATE TABLE db_name.dbo.GPD_PLPerson (
	PLP_ID int NOT NULL,
	PLP_ListID int NULL,
	PLP_Vorname nvarchar(64) COLLATE Latin1_General_CI_AS NULL,
	PLP_Nachname nvarchar(64) COLLATE Latin1_General_CI_AS NULL,
	PLP_Name varchar(132) COLLATE Latin1_General_CI_AS NULL,
	CONSTRAINT GPD_PLPerson_PK PRIMARY KEY (PLP_ID)
);


-- db_name.dbo.GPD_PLStandard definition

-- Drop table

-- DROP TABLE db_name.dbo.GPD_PLStandard;

CREATE TABLE db_name.dbo.GPD_PLStandard (
	PLS_ID int NOT NULL,
	PLS_ListID int NULL,
	PLS_KeySep nvarchar(12) COLLATE Latin1_General_CI_AS NULL,
	PLS_Key nvarchar(12) COLLATE Latin1_General_CI_AS NULL,
	PLS_Name nvarchar(255) COLLATE Latin1_General_CI_AS NULL,
	PLS_PTTypeIndex int NULL,
	PLS_Flag1 int NULL,
	PLS_LAS nvarchar(12) COLLATE Latin1_General_CI_AS NULL,
	PLS_IsSep nvarchar(1) COLLATE Latin1_General_CI_AS NULL,
	CONSTRAINT GPD_PLStandard_PK PRIMARY KEY (PLS_ID)
);


-- db_name.dbo.GPD_StratLists definition

-- Drop table

-- DROP TABLE db_name.dbo.GPD_StratLists;

CREATE TABLE db_name.dbo.GPD_StratLists (
	SLST_ID int NOT NULL,
	SLST_HierarchieBasis int NULL,
	SLST_Bezeichnung nvarchar(255) COLLATE Latin1_General_CI_AS NULL,
	SLST_ProfilTecFile nvarchar(255) COLLATE Latin1_General_CI_AS NULL,
	SLST_Bemerkung nvarchar(255) COLLATE Latin1_General_CI_AS NULL,
	CONSTRAINT GPD_StratLists_PK PRIMARY KEY (SLST_ID)
);


-- db_name.dbo.GPD_Stratigraphie definition

-- Drop table

-- DROP TABLE db_name.dbo.GPD_Stratigraphie;

CREATE TABLE db_name.dbo.GPD_Stratigraphie (
	STRT_ID int NOT NULL,
	STRT_ParentID int NULL,
	STRT_HierarchieStufe int NULL,
	STRT_ListID int NULL,
	STRT_Order int NULL,
	STRT_Kuerzel nvarchar(24) COLLATE Latin1_General_CI_AS NULL,
	STRT_KuerzelOffiziell nvarchar(24) COLLATE Latin1_General_CI_AS NULL,
	STRT_Bezeichnung nvarchar(128) COLLATE Latin1_General_CI_AS NULL,
	STRT_Bemerkung nvarchar(255) COLLATE Latin1_General_CI_AS NULL,
	STRT_LithologieID int NULL,
	STRT_Farbe int NULL,
	STRT_ImportSynonyme nvarchar(255) COLLATE Latin1_General_CI_AS NULL,
	STRT_BereichDefJN nvarchar(1) COLLATE Latin1_General_CI_AS NULL,
	STRT_BereichVon int NULL,
	STRT_BereichBis int NULL,
	STRT_SepZS nvarchar(32) COLLATE Latin1_General_CI_AS NULL,
	STRT_IsSep nvarchar(1) COLLATE Latin1_General_CI_AS NULL,
	CONSTRAINT GPD_Stratigraphie_PK PRIMARY KEY (STRT_ID)
);


-- db_name.dbo.GPD_SynonymKat definition

-- Drop table

-- DROP TABLE db_name.dbo.GPD_SynonymKat;

CREATE TABLE db_name.dbo.GPD_SynonymKat (
	ID int NOT NULL,
	SYN_Sortierung int NULL,
	SYN_Name nvarchar(50) COLLATE Latin1_General_CI_AS NULL,
	Gww nchar(1) COLLATE Latin1_General_CI_AS DEFAULT '-' NULL,
	GwwTransferDate smalldatetime NULL,
	CONSTRAINT GPD_SynonymKat_PK PRIMARY KEY (ID)
);


-- db_name.dbo.GPD_TempAusbau definition

-- Drop table

-- DROP TABLE db_name.dbo.GPD_TempAusbau;

CREATE TABLE db_name.dbo.GPD_TempAusbau (
	MSID int NOT NULL,
	RECID int NOT NULL,
	TARO_OK float NULL,
	TARO_UK float NULL,
	TARO_Typ int NULL,
	TARO_Material int NULL,
	TARO_Durchmesser float NULL,
	TARO_Wandstaerke float NULL,
	TARO_Bemerkung nvarchar(254) COLLATE Latin1_General_CI_AS NULL,
	CONSTRAINT GPD_TempAusbau_PK PRIMARY KEY (MSID,RECID)
);


-- db_name.dbo.GPD_TempSchichten definition

-- Drop table

-- DROP TABLE db_name.dbo.GPD_TempSchichten;

CREATE TABLE db_name.dbo.GPD_TempSchichten (
	MSID int NOT NULL,
	RECID int NOT NULL,
	TSD_UK float NULL,
	TSD_Art nvarchar(128) COLLATE Latin1_General_CI_AS NULL,
	TSD_Stratigrafie nvarchar(254) COLLATE Latin1_General_CI_AS NULL,
	TSD_Petrografie nvarchar(254) COLLATE Latin1_General_CI_AS NULL,
	TSD_Bemerkung nvarchar(254) COLLATE Latin1_General_CI_AS NULL,
	CONSTRAINT GPD_TempSchichten_PK PRIMARY KEY (MSID,RECID)
);


-- db_name.dbo.GWB_AnalyMethods definition

-- Drop table

-- DROP TABLE db_name.dbo.GWB_AnalyMethods;

CREATE TABLE db_name.dbo.GWB_AnalyMethods (
	ID int NOT NULL,
	MethodName varchar(100) COLLATE Latin1_General_CI_AS NULL,
	IsOld varchar(1) COLLATE Latin1_General_CI_AS NULL,
	CONSTRAINT GWB_AnalyMethods_PK PRIMARY KEY (ID)
);


-- db_name.dbo.GWB_Berichte definition

-- Drop table

-- DROP TABLE db_name.dbo.GWB_Berichte;

CREATE TABLE db_name.dbo.GWB_Berichte (
	BerichtsNr int NOT NULL,
	Titel1 nvarchar(50) COLLATE Latin1_General_CI_AS NULL,
	Titel2 nvarchar(50) COLLATE Latin1_General_CI_AS NULL,
	Titel3 nvarchar(50) COLLATE Latin1_General_CI_AS NULL,
	Titel4 nvarchar(50) COLLATE Latin1_General_CI_AS NULL,
	CONSTRAINT GWB_Berichte_PK PRIMARY KEY (BerichtsNr)
);


-- db_name.dbo.GWB_Betreib definition

-- Drop table

-- DROP TABLE db_name.dbo.GWB_Betreib;

CREATE TABLE db_name.dbo.GWB_Betreib (
	Betreiber nvarchar(50) COLLATE Latin1_General_CI_AS NOT NULL,
	KeyNr nvarchar(10) COLLATE Latin1_General_CI_AS NULL,
	CONSTRAINT GWB_Betreib_PK PRIMARY KEY (Betreiber)
);


-- db_name.dbo.GWB_Bohrfirm definition

-- Drop table

-- DROP TABLE db_name.dbo.GWB_Bohrfirm;

CREATE TABLE db_name.dbo.GWB_Bohrfirm (
	Bohrfirma nvarchar(50) COLLATE Latin1_General_CI_AS NOT NULL,
	Adresse1 nvarchar(50) COLLATE Latin1_General_CI_AS NULL,
	Adresse2 nvarchar(50) COLLATE Latin1_General_CI_AS NULL,
	Bemerkungen nvarchar(250) COLLATE Latin1_General_CI_AS NULL,
	KeyNr nvarchar(10) COLLATE Latin1_General_CI_AS NULL,
	CONSTRAINT GWB_Bohrfirm_PK PRIMARY KEY (Bohrfirma)
);


-- db_name.dbo.GWB_Bohrverf definition

-- Drop table

-- DROP TABLE db_name.dbo.GWB_Bohrverf;

CREATE TABLE db_name.dbo.GWB_Bohrverf (
	Bohrverfahren nvarchar(50) COLLATE Latin1_General_CI_AS NOT NULL,
	Bemerkungen nvarchar(250) COLLATE Latin1_General_CI_AS NULL,
	KeyNr nvarchar(10) COLLATE Latin1_General_CI_AS NULL,
	CONSTRAINT GWB_Bohrverf_PK PRIMARY KEY (Bohrverfahren)
);


-- db_name.dbo.GWB_BuildingMaterialCat definition

-- Drop table

-- DROP TABLE db_name.dbo.GWB_BuildingMaterialCat;

CREATE TABLE db_name.dbo.GWB_BuildingMaterialCat (
	ID int NOT NULL,
	ItemName nvarchar(50) COLLATE Latin1_General_CI_AS NOT NULL,
	CONSTRAINT GWB_BuildingMaterialCat_PK PRIMARY KEY (ID)
);


-- db_name.dbo.GWB_CatchmentAreas definition

-- Drop table

-- DROP TABLE db_name.dbo.GWB_CatchmentAreas;

CREATE TABLE db_name.dbo.GWB_CatchmentAreas (
	ID int NOT NULL,
	AreaName varchar(50) COLLATE Latin1_General_CI_AS NOT NULL
);
 CREATE UNIQUE NONCLUSTERED INDEX GWB_CatchmentArea_IDX1 ON db_name.dbo.GWB_CatchmentAreas (  AreaName ASC  )  
	 WITH (  PAD_INDEX = OFF ,FILLFACTOR = 100  ,SORT_IN_TEMPDB = OFF , IGNORE_DUP_KEY = OFF , STATISTICS_NORECOMPUTE = OFF , ONLINE = OFF , ALLOW_ROW_LOCKS = ON , ALLOW_PAGE_LOCKS = ON  )
	 ON [PRIMARY ] ;


-- db_name.dbo.GWB_ChangeLogger definition

-- Drop table

-- DROP TABLE db_name.dbo.GWB_ChangeLogger;

CREATE TABLE db_name.dbo.GWB_ChangeLogger (
	ID bigint IDENTITY(1,1) NOT NULL,
	ModifiedBy nvarchar(20) COLLATE Latin1_General_CI_AS NOT NULL,
	ModifiedDate smalldatetime NOT NULL,
	ModifiedFields text COLLATE Latin1_General_CI_AS NULL,
	CommandType nvarchar(1) COLLATE Latin1_General_CI_AS NULL,
	Tablename nvarchar(50) COLLATE Latin1_General_CI_AS NULL,
	TableDisplayname nvarchar(50) COLLATE Latin1_General_CI_AS NULL,
	IdentifierText nvarchar(50) COLLATE Latin1_General_CI_AS NULL,
	IdentifierID int NULL,
	CONSTRAINT GWB_ChangeLogger_PK PRIMARY KEY (ID)
);


-- db_name.dbo.GWB_CheckRules definition

-- Drop table

-- DROP TABLE db_name.dbo.GWB_CheckRules;

CREATE TABLE db_name.dbo.GWB_CheckRules (
	CR_WellID int NOT NULL,
	CR_ParamID int NOT NULL,
	CR_RuleType smallint NOT NULL,
	CR_CheckValue float NULL,
	CR_ValidFrom smalldatetime NULL,
	CR_ValidUntil smalldatetime NULL,
	CR_ValueType char(1) COLLATE Latin1_General_CI_AS DEFAULT 'A' NULL,
	CR_ValueDescr nvarchar(50) COLLATE Latin1_General_CI_AS NULL,
	CR_Active char(1) COLLATE Latin1_General_CI_AS DEFAULT 'Y' NULL,
	ID int NULL,
	CONSTRAINT GWB_CheckRules_PK PRIMARY KEY (CR_WellID,CR_ParamID,CR_RuleType)
);


-- db_name.dbo.GWB_CheckRules2 definition

-- Drop table

-- DROP TABLE db_name.dbo.GWB_CheckRules2;

CREATE TABLE db_name.dbo.GWB_CheckRules2 (
	CR_ID int NOT NULL,
	CR_WellID int NOT NULL,
	CR_ParamID int NOT NULL,
	CR_RuleType int NOT NULL,
	CR_CheckValue float NULL,
	CR_ValueDescr nvarchar(255) COLLATE Latin1_General_CI_AS NULL,
	CR_Active char(1) COLLATE Latin1_General_CI_AS DEFAULT 'Y' NULL,
	CR_Samples smallint NULL,
	CR_CriticalSamples smallint NULL,
	CR_LookAheadRange smallint NULL,
	CR_LookAheadUnit char(1) COLLATE Latin1_General_CI_AS NULL,
	CR_LookBehindRange smallint NULL,
	CR_LookBehindUnit char(1) COLLATE Latin1_General_CI_AS NULL,
	CONSTRAINT GWB_CheckRules2_PK PRIMARY KEY (CR_ID)
);


-- db_name.dbo.GWB_CheckRules_Templates definition

-- Drop table

-- DROP TABLE db_name.dbo.GWB_CheckRules_Templates;

CREATE TABLE db_name.dbo.GWB_CheckRules_Templates (
	CR_TemplateName nvarchar(100) COLLATE Latin1_General_CI_AS NULL,
	CR_ParamID int NOT NULL,
	CR_RuleType smallint NOT NULL,
	CR_CheckValue float NULL,
	CR_ValidFrom smalldatetime NULL,
	CR_ValidUntil smalldatetime NULL,
	CR_ValueType char(1) COLLATE Latin1_General_CI_AS DEFAULT 'A' NULL,
	CR_ValueDescr nvarchar(50) COLLATE Latin1_General_CI_AS NULL
);


-- db_name.dbo.GWB_Class_Param definition

-- Drop table

-- DROP TABLE db_name.dbo.GWB_Class_Param;

CREATE TABLE db_name.dbo.GWB_Class_Param (
	Param_ID int NOT NULL,
	Class_ID int NOT NULL,
	CONSTRAINT GWB_ClassParam_PK PRIMARY KEY (Param_ID,Class_ID)
);


-- db_name.dbo.GWB_DBVersions definition

-- Drop table

-- DROP TABLE db_name.dbo.GWB_DBVersions;

CREATE TABLE db_name.dbo.GWB_DBVersions (
	ID int NOT NULL,
	PIDrill int NULL,
	PISqlEditor int NULL,
	PIWeb int NULL,
	CONSTRAINT GWB_DBVersions_PK PRIMARY KEY (ID)
);


-- db_name.dbo.GWB_DischargeStatistic definition

-- Drop table

-- DROP TABLE db_name.dbo.GWB_DischargeStatistic;

CREATE TABLE db_name.dbo.GWB_DischargeStatistic (
	Well_ID int NOT NULL,
	StatYear int NULL,
	QSum_1 float NULL,
	QSum_2 float NULL,
	QSum_3 float NULL,
	QSum_4 float NULL,
	QSum_5 float NULL,
	QSum_6 float NULL,
	QSum_7 float NULL,
	QSum_8 float NULL,
	QSum_9 float NULL,
	QSum_10 float NULL,
	QSum_11 float NULL,
	QSum_12 float NULL,
	QSum_Total float NULL,
	QDailyMax_1 float NULL,
	QDateDailyMax_1 smalldatetime NULL,
	QDailyMax_2 float NULL,
	QDateDailyMax_2 smalldatetime NULL,
	QDailyMax_3 float NULL,
	QDateDailyMax_3 smalldatetime NULL,
	QDailyMax_4 float NULL,
	QDateDailyMax_4 smalldatetime NULL,
	QDailyMax_5 float NULL,
	QDateDailyMax_5 smalldatetime NULL,
	QDailyMax_6 float NULL,
	QDateDailyMax_6 smalldatetime NULL,
	QDailyMax_7 float NULL,
	QDateDailyMax_7 smalldatetime NULL,
	QDailyMax_8 float NULL,
	QDateDailyMax_8 smalldatetime NULL,
	QDailyMax_9 float NULL,
	QDateDailyMax_9 smalldatetime NULL,
	QDailyMax_10 float NULL,
	QDateDailyMax_10 smalldatetime NULL,
	QDailyMax_11 float NULL,
	QDateDailyMax_11 smalldatetime NULL,
	QDailyMax_12 float NULL,
	QDateDailyMax_12 smalldatetime NULL
);


-- db_name.dbo.GWB_DocCategories definition

-- Drop table

-- DROP TABLE db_name.dbo.GWB_DocCategories;

CREATE TABLE db_name.dbo.GWB_DocCategories (
	ID int NOT NULL,
	Category nvarchar(50) COLLATE Latin1_General_CI_AS NOT NULL,
	CONSTRAINT GWB_DocCategories_PK PRIMARY KEY (ID)
);


-- db_name.dbo.GWB_DocTypes definition

-- Drop table

-- DROP TABLE db_name.dbo.GWB_DocTypes;

CREATE TABLE db_name.dbo.GWB_DocTypes (
	ID int NOT NULL,
	DocType nvarchar(50) COLLATE Latin1_General_CI_AS NOT NULL,
	CONSTRAINT GWB_DocTypes_PK PRIMARY KEY (ID)
);


-- db_name.dbo.GWB_Einheit definition

-- Drop table

-- DROP TABLE db_name.dbo.GWB_Einheit;

CREATE TABLE db_name.dbo.GWB_Einheit (
	Einheit nvarchar(10) COLLATE Latin1_General_CI_AS NOT NULL,
	KeyNr nvarchar(10) COLLATE Latin1_General_CI_AS NULL,
	Unit_Type int NULL,
	CONSTRAINT GWB_Einheit_PK PRIMARY KEY (Einheit)
);


-- db_name.dbo.GWB_ElevationQuality definition

-- Drop table

-- DROP TABLE db_name.dbo.GWB_ElevationQuality;

CREATE TABLE db_name.dbo.GWB_ElevationQuality (
	ID int NOT NULL,
	QualityText nvarchar(50) COLLATE Latin1_General_CI_AS NOT NULL,
	CONSTRAINT GWB_ElevationQuality_PK PRIMARY KEY (ID)
);


-- db_name.dbo.GWB_FieldChecks definition

-- Drop table

-- DROP TABLE db_name.dbo.GWB_FieldChecks;

CREATE TABLE db_name.dbo.GWB_FieldChecks (
	TName nvarchar(100) COLLATE Latin1_General_CI_AS NOT NULL,
	FName nvarchar(100) COLLATE Latin1_General_CI_AS NOT NULL,
	FNameDisplay nvarchar(100) COLLATE Latin1_General_CI_AS NULL,
	[Options] int NULL,
	ValueMin float NULL,
	ValueMax float NULL,
	FCondition nvarchar(100) COLLATE Latin1_General_CI_AS NULL,
	CONSTRAINT GWB_FieldChecks_PK PRIMARY KEY (TName,FName)
);


-- db_name.dbo.GWB_FlowMeasurementCat definition

-- Drop table

-- DROP TABLE db_name.dbo.GWB_FlowMeasurementCat;

CREATE TABLE db_name.dbo.GWB_FlowMeasurementCat (
	ID int NOT NULL,
	ItemName nvarchar(50) COLLATE Latin1_General_CI_AS NOT NULL,
	CONSTRAINT GWB_FlowMeasurementCat_PK PRIMARY KEY (ID)
);


-- db_name.dbo.GWB_GWStockw definition

-- Drop table

-- DROP TABLE db_name.dbo.GWB_GWStockw;

CREATE TABLE db_name.dbo.GWB_GWStockw (
	ID int NOT NULL,
	GrundwasserStockwerk nvarchar(50) COLLATE Latin1_General_CI_AS NOT NULL,
	SeqNr int NULL,
	KeyNr nvarchar(10) COLLATE Latin1_General_CI_AS NULL,
	CONSTRAINT GWB_GWStockw_PK PRIMARY KEY (ID)
);


-- db_name.dbo.GWB_Geologie definition

-- Drop table

-- DROP TABLE db_name.dbo.GWB_Geologie;

CREATE TABLE db_name.dbo.GWB_Geologie (
	ID int NOT NULL,
	GeologischeEinheit nvarchar(50) COLLATE Latin1_General_CI_AS NOT NULL,
	SeqNr int NULL,
	KeyNr nvarchar(10) COLLATE Latin1_General_CI_AS NULL,
	CONSTRAINT GWB_Geologie_PK PRIMARY KEY (ID)
);


-- db_name.dbo.GWB_Geraete definition

-- Drop table

-- DROP TABLE db_name.dbo.GWB_Geraete;

CREATE TABLE db_name.dbo.GWB_Geraete (
	ProbennahmeGeraet nvarchar(50) COLLATE Latin1_General_CI_AS NOT NULL,
	KeyNr nvarchar(10) COLLATE Latin1_General_CI_AS NULL,
	CONSTRAINT GWB_Geraete_PK PRIMARY KEY (ProbennahmeGeraet)
);


-- db_name.dbo.GWB_Graphics definition

-- Drop table

-- DROP TABLE db_name.dbo.GWB_Graphics;

CREATE TABLE db_name.dbo.GWB_Graphics (
	ID int NOT NULL,
	Well_ID int NULL,
	GraphicFile nvarchar(255) COLLATE Latin1_General_CI_AS NULL,
	FileDescription nvarchar(255) COLLATE Latin1_General_CI_AS NULL,
	FileType nvarchar(10) COLLATE Latin1_General_CI_AS NULL,
	SortNo int NULL,
	Creator_ID int NULL,
	User_ID int NULL,
	Project_ID int NULL,
	DocType_ID int NULL,
	Category_ID int NULL,
	Gww nchar(1) COLLATE Latin1_General_CI_AS DEFAULT '-' NULL,
	GwwFileDate smalldatetime NULL,
	DisplayName nvarchar(64) COLLATE Latin1_General_CI_AS NULL,
	FileOrDir nvarchar(1) COLLATE Latin1_General_CI_AS DEFAULT 'F' NULL,
	CONSTRAINT GWB_Graphics_PK PRIMARY KEY (ID)
);


-- db_name.dbo.GWB_Grenzen definition

-- Drop table

-- DROP TABLE db_name.dbo.GWB_Grenzen;

CREATE TABLE db_name.dbo.GWB_Grenzen (
	XMin float NULL,
	XMax float NULL,
	YMin float NULL,
	YMax float NULL
);


-- db_name.dbo.GWB_Groups definition

-- Drop table

-- DROP TABLE db_name.dbo.GWB_Groups;

CREATE TABLE db_name.dbo.GWB_Groups (
	G_ID int NOT NULL,
	P_ID int NOT NULL,
	G_Type smallint NULL,
	G_Name nvarchar(50) COLLATE Latin1_General_CI_AS NULL,
	G_XCoord float NULL,
	G_YCoord float NULL,
	PO1_ID int NULL,
	PO2_ID int NULL,
	PO1_REF nvarchar(25) COLLATE Latin1_General_CI_AS NULL,
	PO2_REF nvarchar(25) COLLATE Latin1_General_CI_AS NULL,
	G_Comments ntext COLLATE Latin1_General_CI_AS NULL,
	DateChange smalldatetime NULL,
	Proj_ID int NULL,
	CONSTRAINT GWB_Groups_PK PRIMARY KEY (G_ID)
);


-- db_name.dbo.GWB_HChange definition

-- Drop table

-- DROP TABLE db_name.dbo.GWB_HChange;

CREATE TABLE db_name.dbo.GWB_HChange (
	MesstellenID int NOT NULL,
	DatumAenderung smalldatetime NOT NULL,
	NeueHoeheMP float NULL,
	NeueHoeheOKG float NULL,
	Quality_ID int NULL,
	Comment nvarchar(100) COLLATE Latin1_General_CI_AS NULL,
	FilterBtm float NULL,
	CONSTRAINT GWB_HChange_PK PRIMARY KEY (MesstellenID,DatumAenderung)
);


-- db_name.dbo.GWB_Imports definition

-- Drop table

-- DROP TABLE db_name.dbo.GWB_Imports;

CREATE TABLE db_name.dbo.GWB_Imports (
	ID int NOT NULL,
	ImportDate smalldatetime NULL,
	ImportedBy nvarchar(30) COLLATE Latin1_General_CI_AS NULL,
	FileOrDir nvarchar(255) COLLATE Latin1_General_CI_AS NULL,
	NoOfFiles int NULL,
	ImportFormat nvarchar(100) COLLATE Latin1_General_CI_AS NULL,
	CONSTRAINT GWB_Import_PK PRIMARY KEY (ID)
);


-- db_name.dbo.GWB_InOutletStructure definition

-- Drop table

-- DROP TABLE db_name.dbo.GWB_InOutletStructure;

CREATE TABLE db_name.dbo.GWB_InOutletStructure (
	Object_ID int NULL,
	[Length] float NULL,
	Width float NULL,
	Height float NULL,
	GaugeWidth float NULL,
	FilterAreaSize float NULL,
	CommentText text COLLATE Latin1_General_CI_AS NULL
);


-- db_name.dbo.GWB_IonRatios definition

-- Drop table

-- DROP TABLE db_name.dbo.GWB_IonRatios;

CREATE TABLE db_name.dbo.GWB_IonRatios (
	Date_ID int NOT NULL,
	Mg_Ca float NULL,
	Na_Mg float NULL,
	NaK_Cl float NULL,
	Cl_SO4 float NULL,
	Cl_Na float NULL,
	CaMg_NaK float NULL,
	Na_K float NULL,
	Cl_Br float NULL,
	HCO3_ClSO4 float NULL,
	K_Ca float NULL,
	Done nvarchar(1) COLLATE Latin1_General_CI_AS DEFAULT 'N' NULL
);


-- db_name.dbo.GWB_Keyword_Objects definition

-- Drop table

-- DROP TABLE db_name.dbo.GWB_Keyword_Objects;

CREATE TABLE db_name.dbo.GWB_Keyword_Objects (
	Keyword_ID int NOT NULL,
	Object_ID int NOT NULL,
	Object_Type nvarchar(1) COLLATE Latin1_General_CI_AS NOT NULL,
	CONSTRAINT GWB_Keyword_Objects_PK PRIMARY KEY (Keyword_ID,Object_ID,Object_Type)
);


-- db_name.dbo.GWB_Keywords definition

-- Drop table

-- DROP TABLE db_name.dbo.GWB_Keywords;

CREATE TABLE db_name.dbo.GWB_Keywords (
	ID int NOT NULL,
	Keyword nvarchar(50) COLLATE Latin1_General_CI_AS NOT NULL,
	Category_ID int NULL,
	CONSTRAINT GWB_Keywords_PK PRIMARY KEY (ID)
);


-- db_name.dbo.GWB_Labels definition

-- Drop table

-- DROP TABLE db_name.dbo.GWB_Labels;

CREATE TABLE db_name.dbo.GWB_Labels (
	Label_WellNr1 nvarchar(50) COLLATE Latin1_General_CI_AS NULL,
	Label_WellNr2 nvarchar(50) COLLATE Latin1_General_CI_AS NULL,
	Label_WellName nvarchar(50) COLLATE Latin1_General_CI_AS NULL,
	Label_Map nvarchar(50) COLLATE Latin1_General_CI_AS NULL,
	Label_WellType nvarchar(50) COLLATE Latin1_General_CI_AS NULL,
	Label_WellUsage nvarchar(50) COLLATE Latin1_General_CI_AS NULL,
	Label_WellCity nvarchar(50) COLLATE Latin1_General_CI_AS NULL,
	Label_WellDistrict nvarchar(50) COLLATE Latin1_General_CI_AS NULL,
	Label_WellSubDistr nvarchar(50) COLLATE Latin1_General_CI_AS NULL,
	Label_WellSubDistrNo nvarchar(50) COLLATE Latin1_General_CI_AS NULL,
	Label_Position nvarchar(50) COLLATE Latin1_General_CI_AS NULL,
	Label_Owner nvarchar(50) COLLATE Latin1_General_CI_AS NULL,
	Label_OperatedBy nvarchar(50) COLLATE Latin1_General_CI_AS NULL,
	Label_XCoord nvarchar(50) COLLATE Latin1_General_CI_AS NULL,
	Label_YCoord nvarchar(50) COLLATE Latin1_General_CI_AS NULL,
	Label_UserField1 nvarchar(50) COLLATE Latin1_General_CI_AS NULL,
	Label_UserField2 nvarchar(50) COLLATE Latin1_General_CI_AS NULL,
	Label_UserField3 nvarchar(50) COLLATE Latin1_General_CI_AS NULL,
	Label_UserField4 nvarchar(50) COLLATE Latin1_General_CI_AS NULL,
	Label_UserField5 nvarchar(50) COLLATE Latin1_General_CI_AS NULL,
	Label_ProjRefNo1 nvarchar(50) COLLATE Latin1_General_CI_AS NULL,
	Label_ProjRefNo2 nvarchar(50) COLLATE Latin1_General_CI_AS NULL,
	Label_ProjRefNo3 nvarchar(50) COLLATE Latin1_General_CI_AS NULL,
	Label_ProjRefNo4 nvarchar(50) COLLATE Latin1_General_CI_AS NULL,
	Label_ProjRefNo5 nvarchar(50) COLLATE Latin1_General_CI_AS NULL,
	Label_ProjLogic1 nvarchar(50) COLLATE Latin1_General_CI_AS NULL,
	Label_ProjLogic2 nvarchar(50) COLLATE Latin1_General_CI_AS NULL,
	Label_ProjLogic3 nvarchar(50) COLLATE Latin1_General_CI_AS NULL,
	Label_ProjLogic4 nvarchar(50) COLLATE Latin1_General_CI_AS NULL,
	Label_ProjLogic5 nvarchar(50) COLLATE Latin1_General_CI_AS NULL,
	Label_ProjText1 nvarchar(50) COLLATE Latin1_General_CI_AS NULL,
	Label_ProjText2 nvarchar(50) COLLATE Latin1_General_CI_AS NULL,
	Label_ProjText3 nvarchar(50) COLLATE Latin1_General_CI_AS NULL,
	Label_ProjText4 nvarchar(50) COLLATE Latin1_General_CI_AS NULL,
	Label_ProjText5 nvarchar(50) COLLATE Latin1_General_CI_AS NULL,
	Label_SurfaceWater varchar(50) COLLATE Latin1_General_CI_AS NULL,
	Label_SurfaceWaterPart varchar(50) COLLATE Latin1_General_CI_AS NULL,
	Label_SurfaceWaterKm varchar(50) COLLATE Latin1_General_CI_AS NULL,
	Label_SAP_Key nvarchar(50) COLLATE Latin1_General_CI_AS NULL
);


-- db_name.dbo.GWB_Labors definition

-- Drop table

-- DROP TABLE db_name.dbo.GWB_Labors;

CREATE TABLE db_name.dbo.GWB_Labors (
	ID int NOT NULL,
	Labor varchar(100) COLLATE Latin1_General_CI_AS NULL,
	Adresse1 nvarchar(50) COLLATE Latin1_General_CI_AS NULL,
	Adresse2 nvarchar(50) COLLATE Latin1_General_CI_AS NULL,
	Bemerkungen nvarchar(250) COLLATE Latin1_General_CI_AS NULL,
	KeyNr nvarchar(10) COLLATE Latin1_General_CI_AS NULL,
	RelationFile nvarchar(255) COLLATE Latin1_General_CI_AS NULL,
	CONSTRAINT GWB_Labors_PK PRIMARY KEY (ID)
);


-- db_name.dbo.GWB_LevelComments definition

-- Drop table

-- DROP TABLE db_name.dbo.GWB_LevelComments;

CREATE TABLE db_name.dbo.GWB_LevelComments (
	CommentID int NOT NULL,
	CommentText nvarchar(50) COLLATE Latin1_General_CI_AS NULL,
	KeyNr nvarchar(10) COLLATE Latin1_General_CI_AS NULL,
	Quality char(1) COLLATE Latin1_General_CI_AS DEFAULT '+' NULL,
	ToDoCategory_ID int NULL,
	CONSTRAINT GWB_LevelComments_PK PRIMARY KEY (CommentID)
);


-- db_name.dbo.GWB_LevelStatistic definition

-- Drop table

-- DROP TABLE db_name.dbo.GWB_LevelStatistic;

CREATE TABLE db_name.dbo.GWB_LevelStatistic (
	Well_ID int NOT NULL,
	StatYear int NULL,
	MaxLevel_SL float NULL,
	MinLevel_SL float NULL,
	AvLevel_SL float NULL
);


-- db_name.dbo.GWB_Level_Attributes definition

-- Drop table

-- DROP TABLE db_name.dbo.GWB_Level_Attributes;

CREATE TABLE db_name.dbo.GWB_Level_Attributes (
	LA_DATE_ID int NOT NULL,
	LA_Attribute_ID int NOT NULL,
	CONSTRAINT GWB_Level_Attributes_PK PRIMARY KEY (LA_DATE_ID,LA_Attribute_ID)
);


-- db_name.dbo.GWB_Logins definition

-- Drop table

-- DROP TABLE db_name.dbo.GWB_Logins;

CREATE TABLE db_name.dbo.GWB_Logins (
	User_ID int NOT NULL,
	LogInTime smalldatetime NULL,
	LogOffTime smalldatetime NULL
);


-- db_name.dbo.GWB_MAPS definition

-- Drop table

-- DROP TABLE db_name.dbo.GWB_MAPS;

CREATE TABLE db_name.dbo.GWB_MAPS (
	MapFile nvarchar(255) COLLATE Latin1_General_CI_AS NULL,
	MapComment nvarchar(50) COLLATE Latin1_General_CI_AS NOT NULL,
	XMinMap float NULL,
	XMaxMap float NULL,
	YMinMap float NULL,
	YMaxMap float NULL,
	ContourMap char(1) COLLATE Latin1_General_CI_AS DEFAULT 'N' NULL,
	SelectMap char(1) COLLATE Latin1_General_CI_AS DEFAULT 'N' NULL,
	DigitizeMap char(1) COLLATE Latin1_General_CI_AS DEFAULT 'N' NULL,
	BlankArea char(1) COLLATE Latin1_General_CI_AS DEFAULT 'N' NULL,
	BlitMode char(1) COLLATE Latin1_General_CI_AS DEFAULT 'D' NULL,
	PixelsX int NULL,
	PixelsY int NULL,
	Resolution int NULL,
	Project_ID int NULL,
	LineColor int NULL,
	LineWidth int NULL,
	AllwaysUse nvarchar(1) COLLATE Latin1_General_CI_AS NULL,
	ID int NULL,
	UTM_East_MinMap float NULL,
	UTM_North_MinMap float NULL,
	UTM_East_MaxMap float NULL,
	UTM_North_MaxMap float NULL,
	LayerInfo ntext COLLATE Latin1_General_CI_AS NULL,
	MapUseOption int NULL,
	CONSTRAINT GWB_MAPS_PK PRIMARY KEY (MapComment)
);


-- db_name.dbo.GWB_MSArt definition

-- Drop table

-- DROP TABLE db_name.dbo.GWB_MSArt;

CREATE TABLE db_name.dbo.GWB_MSArt (
	MSArt nvarchar(50) COLLATE Latin1_General_CI_AS NOT NULL,
	KeyNr nvarchar(10) COLLATE Latin1_General_CI_AS NULL,
	CONSTRAINT GWB_MSArt_PK PRIMARY KEY (MSArt)
);


-- db_name.dbo.GWB_MSStamm definition

-- Drop table

-- DROP TABLE db_name.dbo.GWB_MSStamm;

CREATE TABLE db_name.dbo.GWB_MSStamm (
	ID int NOT NULL,
	KennNr nvarchar(30) COLLATE Latin1_General_CI_AS NULL,
	KennNr2 nvarchar(30) COLLATE Latin1_General_CI_AS NULL,
	Bezeichnung nvarchar(50) COLLATE Latin1_General_CI_AS NULL,
	Rechtswert float NULL,
	Hochwert float NULL,
	XLabel float NULL,
	YLabel float NULL,
	HoeheMP float NULL,
	HoeheOKG float NULL,
	TK25 nvarchar(20) COLLATE Latin1_General_CI_AS NULL,
	Betreiber nvarchar(50) COLLATE Latin1_General_CI_AS NULL,
	Ort nvarchar(50) COLLATE Latin1_General_CI_AS NULL,
	Gemarkung nvarchar(50) COLLATE Latin1_General_CI_AS NULL,
	Flur nvarchar(20) COLLATE Latin1_General_CI_AS NULL,
	Flurstueck nvarchar(20) COLLATE Latin1_General_CI_AS NULL,
	GrundEigner nvarchar(50) COLLATE Latin1_General_CI_AS NULL,
	Lage nvarchar(100) COLLATE Latin1_General_CI_AS NULL,
	Baujahr char(4) COLLATE Latin1_General_CI_AS NULL,
	Beseitigt char(4) COLLATE Latin1_General_CI_AS NULL,
	Nachfolger nvarchar(20) COLLATE Latin1_General_CI_AS NULL,
	Vorgaenger nvarchar(20) COLLATE Latin1_General_CI_AS NULL,
	Art nvarchar(50) COLLATE Latin1_General_CI_AS NULL,
	Nutzung nvarchar(50) COLLATE Latin1_General_CI_AS NULL,
	Kat1 char(1) COLLATE Latin1_General_CI_AS DEFAULT 'N' NULL,
	Kat2 char(1) COLLATE Latin1_General_CI_AS DEFAULT 'N' NULL,
	Kat3 char(1) COLLATE Latin1_General_CI_AS DEFAULT 'N' NULL,
	Kat4 char(1) COLLATE Latin1_General_CI_AS DEFAULT 'N' NULL,
	Kat5 char(1) COLLATE Latin1_General_CI_AS DEFAULT 'N' NULL,
	Kat6 char(1) COLLATE Latin1_General_CI_AS DEFAULT 'N' NULL,
	Kat7 char(1) COLLATE Latin1_General_CI_AS DEFAULT 'N' NULL,
	Kat8 char(1) COLLATE Latin1_General_CI_AS DEFAULT 'N' NULL,
	Kat9 char(1) COLLATE Latin1_General_CI_AS DEFAULT 'N' NULL,
	Kat10 char(1) COLLATE Latin1_General_CI_AS DEFAULT 'N' NULL,
	LageplanDatei nvarchar(200) COLLATE Latin1_General_CI_AS NULL,
	BildDatei nvarchar(200) COLLATE Latin1_General_CI_AS NULL,
	Bohrfirma nvarchar(50) COLLATE Latin1_General_CI_AS NULL,
	Bohrdurchmesser nvarchar(50) COLLATE Latin1_General_CI_AS NULL,
	Bohrverfahren nvarchar(50) COLLATE Latin1_General_CI_AS NULL,
	Bohrtiefe nvarchar(10) COLLATE Latin1_General_CI_AS NULL,
	Ausbaumaterial nvarchar(50) COLLATE Latin1_General_CI_AS NULL,
	AusbauDurchm nvarchar(50) COLLATE Latin1_General_CI_AS NULL,
	AusbauTiefe nvarchar(10) COLLATE Latin1_General_CI_AS NULL,
	Filterstrecken nvarchar(250) COLLATE Latin1_General_CI_AS NULL,
	FilterTop float NULL,
	FilterBottom float NULL,
	Schlitzweite nvarchar(10) COLLATE Latin1_General_CI_AS NULL,
	Filterkies nvarchar(20) COLLATE Latin1_General_CI_AS NULL,
	Tonsperren nvarchar(50) COLLATE Latin1_General_CI_AS NULL,
	AusbauDatei nvarchar(200) COLLATE Latin1_General_CI_AS NULL,
	Geology_ID int NULL,
	Gesteinsart nvarchar(50) COLLATE Latin1_General_CI_AS NULL,
	KWert nvarchar(10) COLLATE Latin1_General_CI_AS NULL,
	Aquifer_ID int NULL,
	AquiferTop float NULL,
	AquiferBase float NULL,
	GWGespannt char(1) COLLATE Latin1_General_CI_AS DEFAULT 'N' NULL,
	SchichtenDatei nvarchar(200) COLLATE Latin1_General_CI_AS NULL,
	MessintervallWS int NULL,
	LetzteMessung smalldatetime NULL,
	BeprobIntervall int NULL,
	LetzteBeprobung smalldatetime NULL,
	WPlan char(1) COLLATE Latin1_General_CI_AS DEFAULT 'Y' NULL,
	APlan char(1) COLLATE Latin1_General_CI_AS DEFAULT 'Y' NULL,
	UProgrammNr int NULL,
	StatistikAnfang smalldatetime NULL,
	StatistikEnde smalldatetime NULL,
	NNMittel float NULL,
	NNMax float NULL,
	NNMin float NULL,
	FlurabstMittel float NULL,
	FlurabstMax float NULL,
	FlurabstMin float NULL,
	DatumMin smalldatetime NULL,
	DatumMax smalldatetime NULL,
	Symbol int NULL,
	QEinheit char(1) COLLATE Latin1_General_CI_AS NULL,
	QArt char(1) COLLATE Latin1_General_CI_AS NULL,
	Messpunkt nvarchar(25) COLLATE Latin1_General_CI_AS NULL,
	Toleranz float NULL,
	ExtProg1Name nvarchar(20) COLLATE Latin1_General_CI_AS NULL,
	ExtProg1FileExt char(3) COLLATE Latin1_General_CI_AS NULL,
	ExtProg1Path nvarchar(100) COLLATE Latin1_General_CI_AS NULL,
	ExtProg1File nvarchar(200) COLLATE Latin1_General_CI_AS NULL,
	ExtProg2Name nvarchar(20) COLLATE Latin1_General_CI_AS NULL,
	ExtProg2FileExt char(3) COLLATE Latin1_General_CI_AS NULL,
	ExtProg2Path nvarchar(100) COLLATE Latin1_General_CI_AS NULL,
	ExtProg2File nvarchar(200) COLLATE Latin1_General_CI_AS NULL,
	MesspunktBildDatei nvarchar(200) COLLATE Latin1_General_CI_AS NULL,
	Barcode nvarchar(20) COLLATE Latin1_General_CI_AS NULL,
	EntnahmeOrt char(1) COLLATE Latin1_General_CI_AS NULL,
	RLtg_L smallint NULL,
	RLtg_DM smallint NULL,
	Aufsatz_DM smallint NULL,
	GLA_Nr nvarchar(30) COLLATE Latin1_General_CI_AS NULL,
	DateChange smalldatetime NULL,
	AnzahlFilter smallint NULL,
	FilterLaenge float NULL,
	Fassung_ID int NULL,
	P_Rep_ID int NULL,
	NegateLevels nvarchar(1) COLLATE Latin1_General_CI_AS NULL,
	DepthReference nvarchar(1) COLLATE Latin1_General_CI_AS NULL,
	Cnt_Levels int NULL,
	Cnt_Samples int NULL,
	Cnt_Rates int NULL,
	Cnt_Files int NULL,
	UTM_East float NULL,
	UTM_North float NULL,
	VisibleTabs nvarchar(40) COLLATE Latin1_General_CI_AS NULL,
	Web_WellCat nvarchar(2) COLLATE Latin1_General_CI_AS NULL,
	Web_LevelCat nvarchar(2) COLLATE Latin1_General_CI_AS NULL,
	Web_AnalyCat nvarchar(2) COLLATE Latin1_General_CI_AS NULL,
	Web_RateCat nvarchar(2) COLLATE Latin1_General_CI_AS NULL,
	Web_LevelStatCat nvarchar(2) COLLATE Latin1_General_CI_AS NULL,
	Web_AnalyStatCat nvarchar(2) COLLATE Latin1_General_CI_AS NULL,
	Web_RateStatCat nvarchar(2) COLLATE Latin1_General_CI_AS NULL,
	LevelUpperBound float NULL,
	LevelLowerBound float NULL,
	FilterBottom_SL float NULL,
	FilterTop_SL float NULL,
	AbsMaxLevel_SL float NULL,
	AvMaxLevel_SL float NULL,
	AbsMinLevel_SL float NULL,
	AvMinLevel_SL float NULL,
	AvMeanLevel_SL float NULL,
	SeqNo int NULL,
	DateBuild datetime NULL,
	DateDestroyed smalldatetime NULL,
	DrillElevation float NULL,
	SamplingDepth float NULL,
	Status_ID int NULL,
	StandardSamplingType nvarchar(50) COLLATE Latin1_General_CI_AS NULL,
	Stationtype int DEFAULT 1 NULL,
	Gww nchar(1) COLLATE Latin1_General_CI_AS DEFAULT '-' NULL,
	GwwTransferDate smalldatetime NULL,
	GwwLevels nchar(1) COLLATE Latin1_General_CI_AS DEFAULT '-' NULL,
	GwwRates nchar(1) COLLATE Latin1_General_CI_AS DEFAULT '-' NULL,
	GwwAnalyses nchar(1) COLLATE Latin1_General_CI_AS DEFAULT '-' NULL,
	GwwLogger nchar(1) COLLATE Latin1_General_CI_AS DEFAULT '-' NULL,
	GwwRain nchar(1) COLLATE Latin1_General_CI_AS DEFAULT '-' NULL,
	GwwClimate nchar(1) COLLATE Latin1_General_CI_AS DEFAULT '-' NULL,
	GwwFileDate smalldatetime NULL,
	SAP_Key nvarchar(50) COLLATE Latin1_General_CI_AS NULL,
	SurfaceWater_ID int NULL,
	SurfaceWaterPart_ID int NULL,
	km float NULL,
	SurfaceWaterDistance float NULL,
	CatchmentArea_ID int NULL,
	AquiferThickness varchar(20) COLLATE Latin1_General_CI_AS NULL,
	FilterLength float NULL,
	StreetKey nvarchar(20) COLLATE Latin1_General_CI_AS NULL,
	HouseNo nvarchar(10) COLLATE Latin1_General_CI_AS NULL,
	ModifyDate smalldatetime NULL,
	GroupNo nvarchar(50) COLLATE Latin1_General_CI_AS NULL,
	DrilledDepth float NULL,
	SumpTrapLength float NULL,
	CONSTRAINT GWB_MSStamm_PK PRIMARY KEY (ID)
);


-- db_name.dbo.GWB_Manhole definition

-- Drop table

-- DROP TABLE db_name.dbo.GWB_Manhole;

CREATE TABLE db_name.dbo.GWB_Manhole (
	Object_ID int NULL,
	GeometryType nvarchar(1) COLLATE Latin1_General_CI_AS NULL,
	[Length] float NULL,
	Width float NULL,
	Height float NULL,
	Material_ID int NULL,
	AccessGeometryType nvarchar(1) COLLATE Latin1_General_CI_AS NULL,
	AccessLength float NULL,
	AccessWidth float NULL,
	Electrification nvarchar(1) COLLATE Latin1_General_CI_AS NULL,
	RemoteControl nvarchar(1) COLLATE Latin1_General_CI_AS NULL,
	CommentText text COLLATE Latin1_General_CI_AS NULL,
	TotalHeight float NULL
);


-- db_name.dbo.GWB_Maps_Projects definition

-- Drop table

-- DROP TABLE db_name.dbo.GWB_Maps_Projects;

CREATE TABLE db_name.dbo.GWB_Maps_Projects (
	Map_ID int NOT NULL,
	Project_ID int NOT NULL,
	CONSTRAINT GWB_Maps_Projects_PK PRIMARY KEY (Map_ID,Project_ID)
);


-- db_name.dbo.GWB_MeasDate definition

-- Drop table

-- DROP TABLE db_name.dbo.GWB_MeasDate;

CREATE TABLE db_name.dbo.GWB_MeasDate (
	ID int NOT NULL,
	Logger char(1) COLLATE Latin1_General_CI_AS DEFAULT '0' NULL,
	MesstellenID int NULL,
	MessDatum smalldatetime NULL,
	ProgID int NULL,
	[Depth] float NULL,
	Info nvarchar(2) COLLATE Latin1_General_CI_AS NULL,
	Import_ID int NULL,
	DepthRange int NULL,
	Marker nvarchar(1) COLLATE Latin1_General_CI_AS DEFAULT '+' NULL,
	SampleState float NULL,
	CONSTRAINT GWB_MeasDate_PK PRIMARY KEY (ID)
);
 CREATE NONCLUSTERED INDEX IX_Measdate_Logger ON db_name.dbo.GWB_MeasDate (  Logger ASC  , MesstellenID ASC  , MessDatum ASC  )  
	 WITH (  PAD_INDEX = OFF ,FILLFACTOR = 100  ,SORT_IN_TEMPDB = OFF , IGNORE_DUP_KEY = OFF , STATISTICS_NORECOMPUTE = OFF , ONLINE = OFF , ALLOW_ROW_LOCKS = ON , ALLOW_PAGE_LOCKS = ON  )
	 ON [PRIMARY ] ;


-- db_name.dbo.GWB_Memos definition

-- Drop table

-- DROP TABLE db_name.dbo.GWB_Memos;

CREATE TABLE db_name.dbo.GWB_Memos (
	Well_ID int NOT NULL,
	MemoType int NOT NULL,
	DATE_ID int NOT NULL,
	CommentText ntext COLLATE Latin1_General_CI_AS NULL,
	CONSTRAINT GWB_Memos_PK PRIMARY KEY (Well_ID,MemoType,DATE_ID)
);


-- db_name.dbo.GWB_MiscStructure definition

-- Drop table

-- DROP TABLE db_name.dbo.GWB_MiscStructure;

CREATE TABLE db_name.dbo.GWB_MiscStructure (
	Object_ID int NULL,
	CommentText text COLLATE Latin1_General_CI_AS NULL
);


-- db_name.dbo.GWB_NUTZUNG definition

-- Drop table

-- DROP TABLE db_name.dbo.GWB_NUTZUNG;

CREATE TABLE db_name.dbo.GWB_NUTZUNG (
	Nutzung nvarchar(50) COLLATE Latin1_General_CI_AS NOT NULL,
	KeyNr nvarchar(10) COLLATE Latin1_General_CI_AS NULL,
	CONSTRAINT GWB_Nutzung_PK PRIMARY KEY (Nutzung)
);


-- db_name.dbo.GWB_ObjectTypes definition

-- Drop table

-- DROP TABLE db_name.dbo.GWB_ObjectTypes;

CREATE TABLE db_name.dbo.GWB_ObjectTypes (
	ID int NOT NULL,
	Description nvarchar(100) COLLATE Latin1_General_CI_AS NOT NULL,
	CONSTRAINT PK_GWB_ObjectTypes PRIMARY KEY (ID)
);


-- db_name.dbo.GWB_Object_Pipes definition

-- Drop table

-- DROP TABLE db_name.dbo.GWB_Object_Pipes;

CREATE TABLE db_name.dbo.GWB_Object_Pipes (
	ID int NOT NULL,
	Object_ID int NOT NULL,
	ItemName nvarchar(50) COLLATE Latin1_General_CI_AS NOT NULL,
	WaterType_ID int NULL,
	InputPipe_ID int NULL,
	OutputPipe_ID int NULL,
	PipeType_ID int NULL,
	Elevation float NULL,
	Diameter int NULL,
	Material_ID int NULL,
	CONSTRAINT GWB_Object_Pipes_PK PRIMARY KEY (ID)
);


-- db_name.dbo.GWB_Object_TechParts definition

-- Drop table

-- DROP TABLE db_name.dbo.GWB_Object_TechParts;

CREATE TABLE db_name.dbo.GWB_Object_TechParts (
	ID int NOT NULL,
	Object_ID int NULL,
	Part_ID int NULL,
	CommentText nvarchar(255) COLLATE Latin1_General_CI_AS NULL,
	CONSTRAINT GWB_Object_TechParts_PK PRIMARY KEY (ID)
);


-- db_name.dbo.GWB_Organisation definition

-- Drop table

-- DROP TABLE db_name.dbo.GWB_Organisation;

CREATE TABLE db_name.dbo.GWB_Organisation (
	Org_ID int NOT NULL,
	Org_No int NULL,
	Org_Info nvarchar(50) COLLATE Latin1_General_CI_AS NULL,
	Org_Name1 nvarchar(50) COLLATE Latin1_General_CI_AS NULL,
	Org_Name2 nvarchar(50) COLLATE Latin1_General_CI_AS NULL,
	Org_Name3 nvarchar(50) COLLATE Latin1_General_CI_AS NULL,
	Org_Name4 nvarchar(50) COLLATE Latin1_General_CI_AS NULL,
	Org_ZIP1 nvarchar(10) COLLATE Latin1_General_CI_AS NULL,
	Org_Street nvarchar(50) COLLATE Latin1_General_CI_AS NULL,
	Org_ZIP2 nvarchar(10) COLLATE Latin1_General_CI_AS NULL,
	Org_City nvarchar(50) COLLATE Latin1_General_CI_AS NULL,
	Org_Tel nvarchar(25) COLLATE Latin1_General_CI_AS NULL,
	Org_Fax nvarchar(25) COLLATE Latin1_General_CI_AS NULL,
	Org_EMail nvarchar(50) COLLATE Latin1_General_CI_AS NULL,
	DateChange smalldatetime NULL,
	Org_Key nvarchar(20) COLLATE Latin1_General_CI_AS NULL,
	Org_POBox nvarchar(50) COLLATE Latin1_General_CI_AS NULL,
	CONSTRAINT GWB_Organisation_PK PRIMARY KEY (Org_ID)
);


-- db_name.dbo.GWB_PIConfig definition

-- Drop table

-- DROP TABLE db_name.dbo.GWB_PIConfig;

CREATE TABLE db_name.dbo.GWB_PIConfig (
	PIID int NOT NULL,
	FieldName nvarchar(64) COLLATE Latin1_General_CI_AS NOT NULL,
	ValS nvarchar(255) COLLATE Latin1_General_CI_AS NULL,
	ValI int NULL,
	ValF float NULL,
	ValDT smalldatetime NULL,
	CONSTRAINT GWB_PIConfig_PK PRIMARY KEY (PIID,FieldName)
);


-- db_name.dbo.GWB_ParamLists definition

-- Drop table

-- DROP TABLE db_name.dbo.GWB_ParamLists;

CREATE TABLE db_name.dbo.GWB_ParamLists (
	ID int NOT NULL,
	ListName nvarchar(100) COLLATE Latin1_General_CI_AS NULL,
	ParamIDs ntext COLLATE Latin1_General_CI_AS NULL,
	CONSTRAINT GWB_ParamLists_PK PRIMARY KEY (ID)
);


-- db_name.dbo.GWB_PipeMaterialCat definition

-- Drop table

-- DROP TABLE db_name.dbo.GWB_PipeMaterialCat;

CREATE TABLE db_name.dbo.GWB_PipeMaterialCat (
	ID int NOT NULL,
	ItemName nvarchar(50) COLLATE Latin1_General_CI_AS NOT NULL,
	CONSTRAINT GWB_PipeMaterialCat_PK PRIMARY KEY (ID)
);


-- db_name.dbo.GWB_PipeTypeCat definition

-- Drop table

-- DROP TABLE db_name.dbo.GWB_PipeTypeCat;

CREATE TABLE db_name.dbo.GWB_PipeTypeCat (
	ID int NOT NULL,
	ItemName nvarchar(50) COLLATE Latin1_General_CI_AS NOT NULL,
	CONSTRAINT GWB_PipeTypeCat_PK PRIMARY KEY (ID)
);


-- db_name.dbo.GWB_Pipes definition

-- Drop table

-- DROP TABLE db_name.dbo.GWB_Pipes;

CREATE TABLE db_name.dbo.GWB_Pipes (
	ID int NULL,
	PipeName nvarchar(50) COLLATE Latin1_General_CI_AS NULL
);


-- db_name.dbo.GWB_Proben definition

-- Drop table

-- DROP TABLE db_name.dbo.GWB_Proben;

CREATE TABLE db_name.dbo.GWB_Proben (
	DatumID int NOT NULL,
	ProbenNr nvarchar(20) COLLATE Latin1_General_CI_AS NULL,
	ProbenNehmer nvarchar(30) COLLATE Latin1_General_CI_AS NULL,
	Wetter varchar(50) COLLATE Latin1_General_CI_AS NULL,
	Labor varchar(100) COLLATE Latin1_General_CI_AS NULL,
	EntnahmeTiefe float NULL,
	EntnahmeTiefeBis float NULL,
	FoerderRate nvarchar(10) COLLATE Latin1_General_CI_AS NULL,
	FoerderDauer nvarchar(10) COLLATE Latin1_General_CI_AS NULL,
	FoerderGeraet nvarchar(50) COLLATE Latin1_General_CI_AS NULL,
	GeraeteTyp nvarchar(50) COLLATE Latin1_General_CI_AS NULL,
	Probenart varchar(50) COLLATE Latin1_General_CI_AS NULL,
	Truebung varchar(50) COLLATE Latin1_General_CI_AS NULL,
	Farbe varchar(50) COLLATE Latin1_General_CI_AS NULL,
	Geruch varchar(50) COLLATE Latin1_General_CI_AS NULL,
	Bodensatz varchar(50) COLLATE Latin1_General_CI_AS NULL,
	UProgramm int NULL,
	ProgrammEingegeben char(1) COLLATE Latin1_General_CI_AS DEFAULT 'N' NULL,
	SampleDescription nvarchar(100) COLLATE Latin1_General_CI_AS NULL,
	LevelBefore float NULL,
	LevelAfter float NULL,
	LevelConst char(1) COLLATE Latin1_General_CI_AS NULL,
	Locked char(1) COLLATE Latin1_General_CI_AS DEFAULT 'N' NULL,
	Taste varchar(50) COLLATE Latin1_General_CI_AS NULL,
	CreatedBy int NULL,
	UserField1 nvarchar(50) COLLATE Latin1_General_CI_AS NULL,
	UserField2 nvarchar(50) COLLATE Latin1_General_CI_AS NULL,
	UserField3 nvarchar(50) COLLATE Latin1_General_CI_AS NULL,
	UserField4 nvarchar(50) COLLATE Latin1_General_CI_AS NULL,
	UserField5 nvarchar(50) COLLATE Latin1_General_CI_AS NULL,
	Reason_ID int NULL,
	Material_ID int NULL,
	Hardness varchar(50) COLLATE Latin1_General_CI_AS NULL,
	SumCations float NULL,
	SumAnions float NULL,
	SumCationsCeq float NULL,
	SumAnionsCeq float NULL,
	CONSTRAINT GWB_Proben_PK PRIMARY KEY (DatumID)
);


-- db_name.dbo.GWB_ProgGroups definition

-- Drop table

-- DROP TABLE db_name.dbo.GWB_ProgGroups;

CREATE TABLE db_name.dbo.GWB_ProgGroups (
	ID int NOT NULL,
	GroupName nvarchar(50) COLLATE Latin1_General_CI_AS NULL,
	CONSTRAINT GWB_ProgGroups_PK PRIMARY KEY (ID)
);


-- db_name.dbo.GWB_ProgGroups_Progs definition

-- Drop table

-- DROP TABLE db_name.dbo.GWB_ProgGroups_Progs;

CREATE TABLE db_name.dbo.GWB_ProgGroups_Progs (
	Group_ID int NOT NULL,
	Prog_ID int NOT NULL,
	SeqNr int NULL,
	CONSTRAINT GWB_ProgGroups_Progs_PK PRIMARY KEY (Group_ID,Prog_ID)
);


-- db_name.dbo.GWB_Prog_Param definition

-- Drop table

-- DROP TABLE db_name.dbo.GWB_Prog_Param;

CREATE TABLE db_name.dbo.GWB_Prog_Param (
	Prog_ID int NOT NULL,
	SeqNr int NOT NULL,
	Param_ID int NOT NULL,
	DetectLimit float NULL,
	ParamUnit nvarchar(10) COLLATE Latin1_General_CI_AS NULL,
	CONSTRAINT GWB_ProgParam_PK PRIMARY KEY (Prog_ID,SeqNr,Param_ID)
);


-- db_name.dbo.GWB_ProjectSettings definition

-- Drop table

-- DROP TABLE db_name.dbo.GWB_ProjectSettings;

CREATE TABLE db_name.dbo.GWB_ProjectSettings (
	ID int NULL,
	ProjectSettings ntext COLLATE Latin1_General_CI_AS NULL,
	LastOpenDate smalldatetime NULL
);


-- db_name.dbo.GWB_Projects definition

-- Drop table

-- DROP TABLE db_name.dbo.GWB_Projects;

CREATE TABLE db_name.dbo.GWB_Projects (
	ID int NOT NULL,
	ProjectDescr nvarchar(100) COLLATE Latin1_General_CI_AS NULL,
	ProjectComment nvarchar(100) COLLATE Latin1_General_CI_AS NULL,
	ReferenceNo_1 nvarchar(100) COLLATE Latin1_General_CI_AS NULL,
	ReferenceNo_2 nvarchar(100) COLLATE Latin1_General_CI_AS NULL,
	ReferenceNo_3 nvarchar(100) COLLATE Latin1_General_CI_AS NULL,
	ReferenceNo_4 nvarchar(100) COLLATE Latin1_General_CI_AS NULL,
	ReferenceNo_5 nvarchar(100) COLLATE Latin1_General_CI_AS NULL,
	Text_1 nvarchar(100) COLLATE Latin1_General_CI_AS NULL,
	Logical_1 nvarchar(1) COLLATE Latin1_General_CI_AS DEFAULT 'N' NULL,
	Text_2 nvarchar(100) COLLATE Latin1_General_CI_AS NULL,
	Logical_2 nvarchar(1) COLLATE Latin1_General_CI_AS DEFAULT 'N' NULL,
	Text_3 nvarchar(100) COLLATE Latin1_General_CI_AS NULL,
	Logical_3 nvarchar(1) COLLATE Latin1_General_CI_AS DEFAULT 'N' NULL,
	Text_4 nvarchar(100) COLLATE Latin1_General_CI_AS NULL,
	Logical_4 nvarchar(1) COLLATE Latin1_General_CI_AS DEFAULT 'N' NULL,
	Text_5 nvarchar(100) COLLATE Latin1_General_CI_AS NULL,
	Logical_5 nvarchar(1) COLLATE Latin1_General_CI_AS DEFAULT 'N' NULL,
	Gww nchar(1) COLLATE Latin1_General_CI_AS DEFAULT '-' NULL,
	GwwTransferDate smalldatetime NULL,
	Owner_ID int NULL,
	EPSG_Code varchar(20) COLLATE Latin1_General_CI_AS NULL,
	NAD_GRID varchar(200) COLLATE Latin1_General_CI_AS NULL,
	Group_ID int NULL,
	IsDefaultGroup int NULL,
	StationsUnique int DEFAULT 0 NULL,
	CONSTRAINT GWB_Projects_PK PRIMARY KEY (ID)
);
 CREATE UNIQUE NONCLUSTERED INDEX GWB_Projects_IDX2 ON db_name.dbo.GWB_Projects (  ProjectDescr ASC  , Owner_ID ASC  )  
	 WITH (  PAD_INDEX = OFF ,FILLFACTOR = 100  ,SORT_IN_TEMPDB = OFF , IGNORE_DUP_KEY = OFF , STATISTICS_NORECOMPUTE = OFF , ONLINE = OFF , ALLOW_ROW_LOCKS = ON , ALLOW_PAGE_LOCKS = ON  )
	 ON [PRIMARY ] ;


-- db_name.dbo.GWB_Projects_Users definition

-- Drop table

-- DROP TABLE db_name.dbo.GWB_Projects_Users;

CREATE TABLE db_name.dbo.GWB_Projects_Users (
	PU_ProjectID int NOT NULL,
	PU_LoginName nvarchar(20) COLLATE Latin1_General_CI_AS NOT NULL,
	PU_Priv_Wells smallint NULL,
	PU_Priv_Level smallint NULL,
	PU_Priv_Analysis smallint NULL,
	PU_Priv_Discharge smallint NULL,
	PU_Priv_Rainfall smallint NULL,
	CONSTRAINT GWB_ProjectsUsers_PK PRIMARY KEY (PU_ProjectID,PU_LoginName)
);


-- db_name.dbo.GWB_Pump_Data definition

-- Drop table

-- DROP TABLE db_name.dbo.GWB_Pump_Data;

CREATE TABLE db_name.dbo.GWB_Pump_Data (
	ID int NOT NULL,
	Well_ID int NOT NULL,
	Equip_ID int NOT NULL,
	DateAv smalldatetime NULL,
	Head_Vol float NULL,
	Head_Curr float NULL,
	Vol_Curr float NULL,
	DataCount int NULL,
	CONSTRAINT GWB_Pump_Data_PK PRIMARY KEY (ID)
);


-- db_name.dbo.GWB_Pumpen definition

-- Drop table

-- DROP TABLE db_name.dbo.GWB_Pumpen;

CREATE TABLE db_name.dbo.GWB_Pumpen (
	PumpenTyp nvarchar(50) COLLATE Latin1_General_CI_AS NOT NULL,
	KeyNr nvarchar(10) COLLATE Latin1_General_CI_AS NULL,
	CONSTRAINT GWB_Pumpen_PK PRIMARY KEY (PumpenTyp)
);


-- db_name.dbo.GWB_Rainfall definition

-- Drop table

-- DROP TABLE db_name.dbo.GWB_Rainfall;

CREATE TABLE db_name.dbo.GWB_Rainfall (
	WELL_ID int NOT NULL,
	DATE1 smalldatetime NOT NULL,
	DATE2 smalldatetime NULL,
	Rainfall float NULL,
	Import_ID int NULL,
	CONSTRAINT GWB_Rainfall_PK PRIMARY KEY (WELL_ID,DATE1)
);


-- db_name.dbo.GWB_Rates definition

-- Drop table

-- DROP TABLE db_name.dbo.GWB_Rates;

CREATE TABLE db_name.dbo.GWB_Rates (
	MesstellenID int NOT NULL,
	Datum1 smalldatetime NOT NULL,
	Datum2 smalldatetime NULL,
	QWert float NULL,
	OpHours float NULL,
	Import_ID int NULL,
	CurrentReading int NULL,
	CommentText nvarchar(50) COLLATE Latin1_General_CI_AS NULL,
	ValvePosition float NULL,
	OpHoursCounter int NULL,
	CONSTRAINT GWB_Rates_PK PRIMARY KEY (MesstellenID,Datum1)
);


-- db_name.dbo.GWB_ReportGroups definition

-- Drop table

-- DROP TABLE db_name.dbo.GWB_ReportGroups;

CREATE TABLE db_name.dbo.GWB_ReportGroups (
	ID int NOT NULL,
	GroupName nvarchar(100) COLLATE Latin1_General_CI_AS NOT NULL,
	Title1 nvarchar(50) COLLATE Latin1_General_CI_AS NULL,
	Title2 nvarchar(50) COLLATE Latin1_General_CI_AS NULL,
	Title3 nvarchar(50) COLLATE Latin1_General_CI_AS NULL,
	Title4 nvarchar(50) COLLATE Latin1_General_CI_AS NULL,
	CONSTRAINT GWB_ReportGroups_PK PRIMARY KEY (ID)
);


-- db_name.dbo.GWB_ReportGroups_ParamGroups definition

-- Drop table

-- DROP TABLE db_name.dbo.GWB_ReportGroups_ParamGroups;

CREATE TABLE db_name.dbo.GWB_ReportGroups_ParamGroups (
	Group_ID int NOT NULL,
	ParamGroup_ID int NOT NULL,
	CONSTRAINT GWB_ReportGroups_ParamGroups_PK PRIMARY KEY (Group_ID,ParamGroup_ID)
);


-- db_name.dbo.GWB_ReportGroups_Params definition

-- Drop table

-- DROP TABLE db_name.dbo.GWB_ReportGroups_Params;

CREATE TABLE db_name.dbo.GWB_ReportGroups_Params (
	Group_ID int NOT NULL,
	Param_ID int NOT NULL,
	CONSTRAINT GWB_ReportGroups_Params_PK PRIMARY KEY (Group_ID,Param_ID)
);


-- db_name.dbo.GWB_ReportGroups_Stations definition

-- Drop table

-- DROP TABLE db_name.dbo.GWB_ReportGroups_Stations;

CREATE TABLE db_name.dbo.GWB_ReportGroups_Stations (
	Group_ID int NOT NULL,
	Station_ID int NOT NULL,
	CONSTRAINT GWB_ReportGroups_Stations_PK PRIMARY KEY (Group_ID,Station_ID)
);


-- db_name.dbo.GWB_ReportGroups_Templates definition

-- Drop table

-- DROP TABLE db_name.dbo.GWB_ReportGroups_Templates;

CREATE TABLE db_name.dbo.GWB_ReportGroups_Templates (
	ID int NOT NULL,
	Group_ID int NOT NULL,
	ReportTemplate nvarchar(255) COLLATE Latin1_General_CI_AS NOT NULL,
	SeqNo int NOT NULL,
	CONSTRAINT GWB_ReportGroups_Templates_PK PRIMARY KEY (ID)
);


-- db_name.dbo.GWB_SELECTIONS definition

-- Drop table

-- DROP TABLE db_name.dbo.GWB_SELECTIONS;

CREATE TABLE db_name.dbo.GWB_SELECTIONS (
	ID int NOT NULL,
	Owner nvarchar(20) COLLATE Latin1_General_CI_AS NULL,
	CondName nvarchar(255) COLLATE Latin1_General_CI_AS NULL,
	ProjCond nvarchar(255) COLLATE Latin1_General_CI_AS NULL,
	WellCond ntext COLLATE Latin1_General_CI_AS NULL,
	ProgCond nvarchar(255) COLLATE Latin1_General_CI_AS NULL,
	CONSTRAINT GWB_SELECTIONS_PK PRIMARY KEY (ID)
);


-- db_name.dbo.GWB_STOFFKL definition

-- Drop table

-- DROP TABLE db_name.dbo.GWB_STOFFKL;

CREATE TABLE db_name.dbo.GWB_STOFFKL (
	Class_ID int NOT NULL,
	Name nvarchar(50) COLLATE Latin1_General_CI_AS NULL,
	ClassType int NULL,
	Kat1 char(1) COLLATE Latin1_General_CI_AS DEFAULT 'N' NULL,
	Kat2 char(1) COLLATE Latin1_General_CI_AS DEFAULT 'N' NULL,
	Kat3 char(1) COLLATE Latin1_General_CI_AS DEFAULT 'N' NULL,
	Kat4 char(1) COLLATE Latin1_General_CI_AS DEFAULT 'N' NULL,
	Kat5 char(1) COLLATE Latin1_General_CI_AS DEFAULT 'N' NULL,
	Kat6 char(1) COLLATE Latin1_General_CI_AS DEFAULT 'N' NULL,
	Kat7 char(1) COLLATE Latin1_General_CI_AS DEFAULT 'N' NULL,
	Kat8 char(1) COLLATE Latin1_General_CI_AS DEFAULT 'N' NULL,
	Kat9 char(1) COLLATE Latin1_General_CI_AS DEFAULT 'N' NULL,
	Kat10 char(1) COLLATE Latin1_General_CI_AS DEFAULT 'N' NULL,
	StandardEinheit nvarchar(10) COLLATE Latin1_General_CI_AS NULL,
	StandardUnitSoil nvarchar(10) COLLATE Latin1_General_CI_AS NULL,
	StandardUnitEluat nvarchar(10) COLLATE Latin1_General_CI_AS NULL,
	SumParam_ID int NULL,
	Color int NULL,
	SumCalcOnComplete char(1) COLLATE Latin1_General_CI_AS DEFAULT 'N' NULL,
	StandardUnitAir nvarchar(10) COLLATE Latin1_General_CI_AS NULL,
	CONSTRAINT GWB_STOFFKL_PK PRIMARY KEY (Class_ID)
);


-- db_name.dbo.GWB_SYMBOLS definition

-- Drop table

-- DROP TABLE db_name.dbo.GWB_SYMBOLS;

CREATE TABLE db_name.dbo.GWB_SYMBOLS (
	SymbolID int NOT NULL,
	SymbolChar char(1) COLLATE Latin1_General_CI_AS NULL,
	SymbolText nvarchar(50) COLLATE Latin1_General_CI_AS NULL,
	CONSTRAINT GWB_SYMBOLS_PK PRIMARY KEY (SymbolID)
);


-- db_name.dbo.GWB_SampleCalendar definition

-- Drop table

-- DROP TABLE db_name.dbo.GWB_SampleCalendar;

CREATE TABLE db_name.dbo.GWB_SampleCalendar (
	SampleDate int NOT NULL,
	Well_ID int NOT NULL,
	ProgGroup_ID int NOT NULL,
	Done nvarchar(1) COLLATE Latin1_General_CI_AS NULL,
	CONSTRAINT GWB_SampleCaledar_PK PRIMARY KEY (SampleDate,Well_ID)
);


-- db_name.dbo.GWB_SampleColor definition

-- Drop table

-- DROP TABLE db_name.dbo.GWB_SampleColor;

CREATE TABLE db_name.dbo.GWB_SampleColor (
	Color nvarchar(20) COLLATE Latin1_General_CI_AS NOT NULL,
	KeyNr nvarchar(10) COLLATE Latin1_General_CI_AS NULL,
	CONSTRAINT GWB_SampleColor_PK PRIMARY KEY (Color)
);


-- db_name.dbo.GWB_SampleMaterial definition

-- Drop table

-- DROP TABLE db_name.dbo.GWB_SampleMaterial;

CREATE TABLE db_name.dbo.GWB_SampleMaterial (
	ID int NOT NULL,
	ShortName nvarchar(24) COLLATE Latin1_General_CI_AS NULL,
	LongName nvarchar(80) COLLATE Latin1_General_CI_AS NULL,
	CONSTRAINT GWB_SampleMaterial_PK PRIMARY KEY (ID)
);


-- db_name.dbo.GWB_SampleSediment definition

-- Drop table

-- DROP TABLE db_name.dbo.GWB_SampleSediment;

CREATE TABLE db_name.dbo.GWB_SampleSediment (
	Sediment nvarchar(20) COLLATE Latin1_General_CI_AS NOT NULL,
	KeyNr nvarchar(10) COLLATE Latin1_General_CI_AS NULL,
	CONSTRAINT GWB_SampleSediment_PK PRIMARY KEY (Sediment)
);


-- db_name.dbo.GWB_SampleSmell definition

-- Drop table

-- DROP TABLE db_name.dbo.GWB_SampleSmell;

CREATE TABLE db_name.dbo.GWB_SampleSmell (
	Smell nvarchar(20) COLLATE Latin1_General_CI_AS NOT NULL,
	KeyNr nvarchar(10) COLLATE Latin1_General_CI_AS NULL,
	CONSTRAINT GWB_SampleSmell_PK PRIMARY KEY (Smell)
);


-- db_name.dbo.GWB_SampleTurbidity definition

-- Drop table

-- DROP TABLE db_name.dbo.GWB_SampleTurbidity;

CREATE TABLE db_name.dbo.GWB_SampleTurbidity (
	Turbidity nvarchar(20) COLLATE Latin1_General_CI_AS NOT NULL,
	KeyNr nvarchar(10) COLLATE Latin1_General_CI_AS NULL,
	CONSTRAINT GWB_SampleTurbidity_PK PRIMARY KEY (Turbidity)
);


-- db_name.dbo.GWB_SampleType definition

-- Drop table

-- DROP TABLE db_name.dbo.GWB_SampleType;

CREATE TABLE db_name.dbo.GWB_SampleType (
	SampleType nvarchar(30) COLLATE Latin1_General_CI_AS NOT NULL,
	KeyNr nvarchar(10) COLLATE Latin1_General_CI_AS NULL,
	CONSTRAINT GWB_SampleType_PK PRIMARY KEY (SampleType)
);


-- db_name.dbo.GWB_SampleWeather definition

-- Drop table

-- DROP TABLE db_name.dbo.GWB_SampleWeather;

CREATE TABLE db_name.dbo.GWB_SampleWeather (
	Weather nvarchar(20) COLLATE Latin1_General_CI_AS NOT NULL,
	KeyNr nvarchar(10) COLLATE Latin1_General_CI_AS NULL,
	CONSTRAINT GWB_SampleWeather_PK PRIMARY KEY (Weather)
);


-- db_name.dbo.GWB_Samples_Progs definition

-- Drop table

-- DROP TABLE db_name.dbo.GWB_Samples_Progs;

CREATE TABLE db_name.dbo.GWB_Samples_Progs (
	Sample_ID int NOT NULL,
	Prog_ID int NOT NULL,
	SeqNr int NULL,
	CONSTRAINT GWB_SamplesProgs_PK PRIMARY KEY (Sample_ID,Prog_ID)
);


-- db_name.dbo.GWB_SamplingReasons definition

-- Drop table

-- DROP TABLE db_name.dbo.GWB_SamplingReasons;

CREATE TABLE db_name.dbo.GWB_SamplingReasons (
	ID int NOT NULL,
	Reason nvarchar(50) COLLATE Latin1_General_CI_AS NULL,
	KeyNr nvarchar(10) COLLATE Latin1_General_CI_AS NULL,
	CONSTRAINT GWB_SamplingReasons_PK PRIMARY KEY (ID)
);


-- db_name.dbo.GWB_SiteOwners definition

-- Drop table

-- DROP TABLE db_name.dbo.GWB_SiteOwners;

CREATE TABLE db_name.dbo.GWB_SiteOwners (
	ID int NOT NULL,
	Name nvarchar(50) COLLATE Latin1_General_CI_AS NULL,
	ZIP nvarchar(10) COLLATE Latin1_General_CI_AS NULL,
	Street nvarchar(50) COLLATE Latin1_General_CI_AS NULL,
	Town nvarchar(50) COLLATE Latin1_General_CI_AS NULL,
	Tel nvarchar(20) COLLATE Latin1_General_CI_AS NULL,
	CONSTRAINT GWB_SiteeOwners_PK PRIMARY KEY (ID)
);


-- db_name.dbo.GWB_Spec_Yield definition

-- Drop table

-- DROP TABLE db_name.dbo.GWB_Spec_Yield;

CREATE TABLE db_name.dbo.GWB_Spec_Yield (
	ID int NOT NULL,
	Well_ID int NOT NULL,
	MDate smalldatetime NULL,
	Drawdown float NULL,
	Flow float NULL,
	CommentText nvarchar(50) COLLATE Latin1_General_CI_AS NULL,
	MDate_Static smalldatetime NULL,
	Static_Level float NULL,
	Pressure float NULL,
	Power float NULL,
	CONSTRAINT GWB_Spec_Yield_PK PRIMARY KEY (ID)
);


-- db_name.dbo.GWB_SqlRecherche definition

-- Drop table

-- DROP TABLE db_name.dbo.GWB_SqlRecherche;

CREATE TABLE db_name.dbo.GWB_SqlRecherche (
	ID int NOT NULL,
	Art nvarchar(1) COLLATE Latin1_General_CI_AS NULL,
	Bezeichnung nvarchar(64) COLLATE Latin1_General_CI_AS NULL,
	Beschreibung nvarchar(128) COLLATE Latin1_General_CI_AS NULL,
	Gruppe int NULL,
	KmsAlle nvarchar(1) COLLATE Latin1_General_CI_AS NULL,
	KmsTeilgebiet int NULL,
	KmsRoute int NULL,
	KmsHWStockW int NULL,
	KmsGeolEinheit int NULL,
	KwsWasserstandJN nvarchar(1) COLLATE Latin1_General_CI_AS NULL,
	KwsPerson int NULL,
	KwsKennung nvarchar(1) COLLATE Latin1_General_CI_AS NULL,
	KwsAttribut int NULL,
	KwsHinweisJN nvarchar(1) COLLATE Latin1_General_CI_AS NULL,
	KwsMitOhneWert nvarchar(1) COLLATE Latin1_General_CI_AS NULL,
	KwsRelation nvarchar(1) COLLATE Latin1_General_CI_AS NULL,
	KwsWert float NULL,
	KwsBezug nvarchar(1) COLLATE Latin1_General_CI_AS NULL,
	KwsWsUnterFilterUK nvarchar(1) COLLATE Latin1_General_CI_AS NULL,
	KwsGeloteteTiefe nvarchar(1) COLLATE Latin1_General_CI_AS NULL,
	KpbProbeJN nvarchar(1) COLLATE Latin1_General_CI_AS NULL,
	KpbErledigtJN nvarchar(1) COLLATE Latin1_General_CI_AS NULL,
	KpbProbennehmer nvarchar(64) COLLATE Latin1_General_CI_AS NULL,
	KpbUProgramm int NULL,
	KayAnalyseJN nvarchar(1) COLLATE Latin1_General_CI_AS NULL,
	KayMitParam nvarchar(1) COLLATE Latin1_General_CI_AS NULL,
	KayParamAnzahl nvarchar(1) COLLATE Latin1_General_CI_AS NULL,
	KayMitOhneWert nvarchar(1) COLLATE Latin1_General_CI_AS NULL,
	KayParameter int NULL,
	KayRelation nvarchar(1) COLLATE Latin1_General_CI_AS NULL,
	KayWert float NULL,
	KayLabor int NULL,
	KdtDatumJN nvarchar(1) COLLATE Latin1_General_CI_AS NULL,
	VisColLage nvarchar(1) COLLATE Latin1_General_CI_AS NULL,
	VisColAnalyMethod nvarchar(1) COLLATE Latin1_General_CI_AS NULL,
	CONSTRAINT GWB_SqlRecherche_PK PRIMARY KEY (ID)
);


-- db_name.dbo.GWB_StationReports definition

-- Drop table

-- DROP TABLE db_name.dbo.GWB_StationReports;

CREATE TABLE db_name.dbo.GWB_StationReports (
	ID int NOT NULL,
	Description nvarchar(50) COLLATE Latin1_General_CI_AS NULL,
	SortOrder int NULL,
	Parameter_ID int NOT NULL,
	Stn1_ID int NULL,
	Stn2_ID int NULL,
	Stn3_ID int NULL,
	Stn4_ID int NULL,
	Stn5_ID int NULL,
	Stn6_ID int NULL,
	Stn7_ID int NULL,
	Stn8_ID int NULL,
	Stn9_ID int NULL,
	Stn10_ID int NULL,
	ThresholdText nvarchar(50) COLLATE Latin1_General_CI_AS NULL,
	ThresholdValue float NULL,
	CONSTRAINT GWB_StationReports_PK PRIMARY KEY (ID)
);


-- db_name.dbo.GWB_StnFlowDeviceHistory definition

-- Drop table

-- DROP TABLE db_name.dbo.GWB_StnFlowDeviceHistory;

CREATE TABLE db_name.dbo.GWB_StnFlowDeviceHistory (
	ID int NOT NULL,
	Station_ID int NOT NULL,
	FlowDevice_ID int NOT NULL,
	FlowDeviceDate smalldatetime NOT NULL,
	FlowDeviceCommentText nvarchar(100) COLLATE Latin1_General_CI_AS NULL,
	CONSTRAINT GWB_StnFlowDeviceHistory_PK PRIMARY KEY (ID)
);


-- db_name.dbo.GWB_StoredRiverNet_Aquifers definition

-- Drop table

-- DROP TABLE db_name.dbo.GWB_StoredRiverNet_Aquifers;

CREATE TABLE db_name.dbo.GWB_StoredRiverNet_Aquifers (
	StoredRiverNet_ID int NOT NULL,
	Aquifer_ID int NOT NULL,
	CONSTRAINT GWB_SRNetAqui_PK PRIMARY KEY (StoredRiverNet_ID,Aquifer_ID)
);


-- db_name.dbo.GWB_StoredRiverNet_Points definition

-- Drop table

-- DROP TABLE db_name.dbo.GWB_StoredRiverNet_Points;

CREATE TABLE db_name.dbo.GWB_StoredRiverNet_Points (
	StoredRiverNet_ID int NOT NULL,
	SeqNr int NOT NULL,
	X float NULL,
	Y float NULL,
	Z float NULL,
	ConnectionType smallint NULL,
	ConnectionFactor float NULL,
	CONSTRAINT GWB_SRNetPnts_PK PRIMARY KEY (StoredRiverNet_ID,SeqNr)
);


-- db_name.dbo.GWB_StoredRiverNets definition

-- Drop table

-- DROP TABLE db_name.dbo.GWB_StoredRiverNets;

CREATE TABLE db_name.dbo.GWB_StoredRiverNets (
	ID int NOT NULL,
	RiverNetName nvarchar(50) COLLATE Latin1_General_CI_AS NULL,
	CONSTRAINT GWB_SRNet_PK PRIMARY KEY (ID)
);


-- db_name.dbo.GWB_StreetCat definition

-- Drop table

-- DROP TABLE db_name.dbo.GWB_StreetCat;

CREATE TABLE db_name.dbo.GWB_StreetCat (
	StreetKey nvarchar(20) COLLATE Latin1_General_CI_AS NOT NULL,
	StreetName nvarchar(100) COLLATE Latin1_General_CI_AS NOT NULL,
	CONSTRAINT GWB_StreetCat_PK PRIMARY KEY (StreetKey)
);


-- db_name.dbo.GWB_StructParts definition

-- Drop table

-- DROP TABLE db_name.dbo.GWB_StructParts;

CREATE TABLE db_name.dbo.GWB_StructParts (
	ID int NOT NULL,
	Struct_ID int NULL,
	StructPartName nvarchar(50) COLLATE Latin1_General_CI_AS NULL,
	ConnectionType smallint NULL,
	ConnectionFactor float NULL,
	ElevationTop float NULL,
	NextPart_ID int NULL,
	PrevPart_ID int NULL,
	CONSTRAINT GWB_StructParts_PK PRIMARY KEY (ID)
);


-- db_name.dbo.GWB_StructParts_Aquifers definition

-- Drop table

-- DROP TABLE db_name.dbo.GWB_StructParts_Aquifers;

CREATE TABLE db_name.dbo.GWB_StructParts_Aquifers (
	StructPart_ID int NOT NULL,
	Aquifer_ID int NOT NULL,
	CONSTRAINT GWB_StructPartAqui_PK PRIMARY KEY (StructPart_ID,Aquifer_ID)
);


-- db_name.dbo.GWB_StructParts_Points definition

-- Drop table

-- DROP TABLE db_name.dbo.GWB_StructParts_Points;

CREATE TABLE db_name.dbo.GWB_StructParts_Points (
	StructPart_ID int NOT NULL,
	Point_ID int NOT NULL,
	NextPoint_ID int NULL,
	PrevPoint_ID int NULL,
	CONSTRAINT GWB_SPPoints_PK PRIMARY KEY (StructPart_ID,Point_ID)
);


-- db_name.dbo.GWB_StructPoints definition

-- Drop table

-- DROP TABLE db_name.dbo.GWB_StructPoints;

CREATE TABLE db_name.dbo.GWB_StructPoints (
	ID int NOT NULL,
	X float NULL,
	Y float NULL,
	Station_ID int NULL,
	CONSTRAINT GWB_StructPoints_PK PRIMARY KEY (ID)
);


-- db_name.dbo.GWB_Structures definition

-- Drop table

-- DROP TABLE db_name.dbo.GWB_Structures;

CREATE TABLE db_name.dbo.GWB_Structures (
	ID int NOT NULL,
	StructName nvarchar(50) COLLATE Latin1_General_CI_AS NULL,
	StructType char(1) COLLATE Latin1_General_CI_AS NULL,
	Priority smallint NULL,
	CONSTRAINT GWB_Structures_PK PRIMARY KEY (ID)
);


-- db_name.dbo.GWB_SurfaceWaters definition

-- Drop table

-- DROP TABLE db_name.dbo.GWB_SurfaceWaters;

CREATE TABLE db_name.dbo.GWB_SurfaceWaters (
	ID int NOT NULL,
	ItemName varchar(50) COLLATE Latin1_General_CI_AS NOT NULL,
	CONSTRAINT GWB_SurfaceWaters_PK PRIMARY KEY (ID)
);
 CREATE UNIQUE NONCLUSTERED INDEX GWB_SurfaceWaters_IDX1 ON db_name.dbo.GWB_SurfaceWaters (  ItemName ASC  )  
	 WITH (  PAD_INDEX = OFF ,FILLFACTOR = 100  ,SORT_IN_TEMPDB = OFF , IGNORE_DUP_KEY = OFF , STATISTICS_NORECOMPUTE = OFF , ONLINE = OFF , ALLOW_ROW_LOCKS = ON , ALLOW_PAGE_LOCKS = ON  )
	 ON [PRIMARY ] ;


-- db_name.dbo.GWB_SymbolsCategories definition

-- Drop table

-- DROP TABLE db_name.dbo.GWB_SymbolsCategories;

CREATE TABLE db_name.dbo.GWB_SymbolsCategories (
	ID int NOT NULL,
	Field_Name nvarchar(50) COLLATE Latin1_General_CI_AS NOT NULL,
	Category nvarchar(100) COLLATE Latin1_General_CI_AS NULL,
	Icon nvarchar(100) COLLATE Latin1_General_CI_AS NULL,
	IconPosition nvarchar(1) COLLATE Latin1_General_CI_AS NULL,
	CONSTRAINT GWB_SymbolsCategories_PK PRIMARY KEY (ID)
);


-- db_name.dbo.GWB_Taste definition

-- Drop table

-- DROP TABLE db_name.dbo.GWB_Taste;

CREATE TABLE db_name.dbo.GWB_Taste (
	ID int NOT NULL,
	Taste varchar(50) COLLATE Latin1_General_CI_AS NULL,
	KeyNr nvarchar(10) COLLATE Latin1_General_CI_AS NULL,
	CONSTRAINT GWB_Taste_PK PRIMARY KEY (ID)
);


-- db_name.dbo.GWB_TechEquip_History definition

-- Drop table

-- DROP TABLE db_name.dbo.GWB_TechEquip_History;

CREATE TABLE db_name.dbo.GWB_TechEquip_History (
	ID int NOT NULL,
	Equip_ID int NOT NULL,
	Well_ID int NULL,
	StartDate smalldatetime NULL,
	EndDate smalldatetime NULL,
	HistoryType char(1) COLLATE Latin1_General_CI_AS NULL,
	CONSTRAINT GWB_TechEquip_History_PK PRIMARY KEY (ID)
);


-- db_name.dbo.GWB_TechEquip_ManufacturerCat definition

-- Drop table

-- DROP TABLE db_name.dbo.GWB_TechEquip_ManufacturerCat;

CREATE TABLE db_name.dbo.GWB_TechEquip_ManufacturerCat (
	ID int NOT NULL,
	Manufacturer nvarchar(70) COLLATE Latin1_General_CI_AS NOT NULL,
	CONSTRAINT GWB_TechEquip_ManufacturerCat_PK PRIMARY KEY (ID)
);


-- db_name.dbo.GWB_TechEquip_Repairs definition

-- Drop table

-- DROP TABLE db_name.dbo.GWB_TechEquip_Repairs;

CREATE TABLE db_name.dbo.GWB_TechEquip_Repairs (
	ID int NOT NULL,
	Equip_ID int NOT NULL,
	History_ID int NOT NULL,
	Address nvarchar(255) COLLATE Latin1_General_CI_AS NULL,
	Person nvarchar(30) COLLATE Latin1_General_CI_AS NULL,
	RepairReason nvarchar(255) COLLATE Latin1_General_CI_AS NULL,
	RepairCosts float NULL,
	Remarks ntext COLLATE Latin1_General_CI_AS NULL,
	CONSTRAINT GWB_TechEquip_Repairs_PK PRIMARY KEY (ID)
);


-- db_name.dbo.GWB_TechEquip_Stores definition

-- Drop table

-- DROP TABLE db_name.dbo.GWB_TechEquip_Stores;

CREATE TABLE db_name.dbo.GWB_TechEquip_Stores (
	ID int NOT NULL,
	Equip_ID int NOT NULL,
	History_ID int NOT NULL,
	StoreAddress nvarchar(255) COLLATE Latin1_General_CI_AS NULL,
	Remarks ntext COLLATE Latin1_General_CI_AS NULL,
	CONSTRAINT GWB_TechEquip_Stores_PK PRIMARY KEY (ID)
);


-- db_name.dbo.GWB_TechEquip_TypeCat definition

-- Drop table

-- DROP TABLE db_name.dbo.GWB_TechEquip_TypeCat;

CREATE TABLE db_name.dbo.GWB_TechEquip_TypeCat (
	ID int NOT NULL,
	EquipType nvarchar(70) COLLATE Latin1_General_CI_AS NOT NULL,
	CONSTRAINT GWB_TechEquip_TypeCat_PK PRIMARY KEY (ID)
);


-- db_name.dbo.GWB_TechEquip_Wells definition

-- Drop table

-- DROP TABLE db_name.dbo.GWB_TechEquip_Wells;

CREATE TABLE db_name.dbo.GWB_TechEquip_Wells (
	ID int NOT NULL,
	Equip_ID int NOT NULL,
	History_ID int NOT NULL,
	[Depth] float NULL,
	DepthUnit nvarchar(5) COLLATE Latin1_General_CI_AS NULL,
	Remarks ntext COLLATE Latin1_General_CI_AS NULL,
	CONSTRAINT GWB_TechEquip_Wells_PK PRIMARY KEY (ID)
);


-- db_name.dbo.GWB_TechEquipment definition

-- Drop table

-- DROP TABLE db_name.dbo.GWB_TechEquipment;

CREATE TABLE db_name.dbo.GWB_TechEquipment (
	ID int NOT NULL,
	Category char(1) COLLATE Latin1_General_CI_AS NULL,
	[Type] nvarchar(50) COLLATE Latin1_General_CI_AS NULL,
	Person nvarchar(30) COLLATE Latin1_General_CI_AS NULL,
	InventoryNo nvarchar(50) COLLATE Latin1_General_CI_AS NULL,
	Material nvarchar(20) COLLATE Latin1_General_CI_AS NULL,
	Price float NULL,
	DateAquired smalldatetime NULL,
	Manufacturer nvarchar(50) COLLATE Latin1_General_CI_AS NULL,
	YearMade smallint NULL,
	Remarks ntext COLLATE Latin1_General_CI_AS NULL,
	DataFile nvarchar(255) COLLATE Latin1_General_CI_AS NULL,
	RatedFlow float NULL,
	RatedFlowUnit nvarchar(10) COLLATE Latin1_General_CI_AS NULL,
	RatedCurrent float NULL,
	RatedHead float NULL,
	RatedHeadUnit nvarchar(5) COLLATE Latin1_General_CI_AS NULL,
	Diameter float NULL,
	DiameterUnit nvarchar(5) COLLATE Latin1_General_CI_AS NULL,
	[Length] float NULL,
	LengthUnit nvarchar(5) COLLATE Latin1_General_CI_AS NULL,
	SystemLength float NULL,
	SystemLengthUnit nvarchar(5) COLLATE Latin1_General_CI_AS NULL,
	SIMCardNo nvarchar(20) COLLATE Latin1_General_CI_AS NULL,
	SerialNo nvarchar(50) COLLATE Latin1_General_CI_AS NULL,
	InActive nvarchar(1) COLLATE Latin1_General_CI_AS DEFAULT 'N' NULL,
	CONSTRAINT GWB_TechEquipment_PK PRIMARY KEY (ID)
);


-- db_name.dbo.GWB_TechPartsCat definition

-- Drop table

-- DROP TABLE db_name.dbo.GWB_TechPartsCat;

CREATE TABLE db_name.dbo.GWB_TechPartsCat (
	ID int NOT NULL,
	Class_ID int NOT NULL,
	ItemName nvarchar(50) COLLATE Latin1_General_CI_AS NOT NULL,
	CONSTRAINT GWB_TechPartsCat_PK PRIMARY KEY (ID)
);


-- db_name.dbo.GWB_TechPartsClassCat definition

-- Drop table

-- DROP TABLE db_name.dbo.GWB_TechPartsClassCat;

CREATE TABLE db_name.dbo.GWB_TechPartsClassCat (
	ID int NOT NULL,
	ItemName nvarchar(50) COLLATE Latin1_General_CI_AS NOT NULL,
	CONSTRAINT GWB_TechPartsClassCat_PK PRIMARY KEY (ID)
);


-- db_name.dbo.GWB_ToDoCategories definition

-- Drop table

-- DROP TABLE db_name.dbo.GWB_ToDoCategories;

CREATE TABLE db_name.dbo.GWB_ToDoCategories (
	ID int NOT NULL,
	CategoryName nvarchar(50) COLLATE Latin1_General_CI_AS NULL,
	SAP_Key nvarchar(50) COLLATE Latin1_General_CI_AS NULL,
	RepeatMonths int NULL,
	CONSTRAINT GWB_ToDoCategories_PK PRIMARY KEY (ID)
);


-- db_name.dbo.GWB_Topograf definition

-- Drop table

-- DROP TABLE db_name.dbo.GWB_Topograf;

CREATE TABLE db_name.dbo.GWB_Topograf (
	Project_ID int NOT NULL,
	Rechtswert float NOT NULL,
	Hochwert float NOT NULL,
	HoeheNN float NULL,
	CONSTRAINT GWB_Topograf_PK PRIMARY KEY (Project_ID,Rechtswert,Hochwert)
);


-- db_name.dbo.GWB_UKat definition

-- Drop table

-- DROP TABLE db_name.dbo.GWB_UKat;

CREATE TABLE db_name.dbo.GWB_UKat (
	KatalogNr int NOT NULL,
	KatalogBezeichnung nvarchar(50) COLLATE Latin1_General_CI_AS NULL,
	KatalogType int NULL,
	SeqNr int NULL,
	Lab_ID int NULL,
	Active varchar(1) COLLATE Latin1_General_CI_AS NULL,
	CONSTRAINT GWB_UKat_PK PRIMARY KEY (KatalogNr)
);


-- db_name.dbo.GWB_UMRECH definition

-- Drop table

-- DROP TABLE db_name.dbo.GWB_UMRECH;

CREATE TABLE db_name.dbo.GWB_UMRECH (
	Einheit1 nvarchar(10) COLLATE Latin1_General_CI_AS NOT NULL,
	Einheit2 nvarchar(10) COLLATE Latin1_General_CI_AS NOT NULL,
	Faktor float NULL,
	CONSTRAINT GWB_UMRECH_PK PRIMARY KEY (Einheit1,Einheit2)
);


-- db_name.dbo.GWB_UserSelection definition

-- Drop table

-- DROP TABLE db_name.dbo.GWB_UserSelection;

CREATE TABLE db_name.dbo.GWB_UserSelection (
	User_ID int NOT NULL,
	Well_ID int NOT NULL,
	List_Type int NULL
);


-- db_name.dbo.GWB_Users definition

-- Drop table

-- DROP TABLE db_name.dbo.GWB_Users;

CREATE TABLE db_name.dbo.GWB_Users (
	US_LoginName nvarchar(20) COLLATE Latin1_General_CI_AS NOT NULL,
	US_UserName nvarchar(30) COLLATE Latin1_General_CI_AS NULL,
	US_Password nvarchar(10) COLLATE Latin1_General_CI_AS NULL,
	US_IsAdmin char(1) COLLATE Latin1_General_CI_AS DEFAULT 'N' NULL,
	US_AllowLookupLists char(1) COLLATE Latin1_General_CI_AS DEFAULT 'Y' NULL,
	US_AllowWarnList char(1) COLLATE Latin1_General_CI_AS DEFAULT 'Y' NULL,
	US_PrivateMaps char(1) COLLATE Latin1_General_CI_AS DEFAULT 'Y' NULL,
	US_LastUser char(1) COLLATE Latin1_General_CI_AS NULL,
	US_TableLayoutChange nvarchar(1) COLLATE Latin1_General_CI_AS NULL,
	ID int NULL,
	US_LoggerData nvarchar(1) COLLATE Latin1_General_CI_AS NULL,
	U_Priv_Wells int NULL,
	U_Priv_Level int NULL,
	U_Priv_Analysis int NULL,
	U_Priv_Discharge int NULL,
	U_Priv_Rainfall int NULL,
	US_PrivateSubProjects nvarchar(1) COLLATE Latin1_General_CI_AS NULL,
	US_WinUserName varchar(255) COLLATE Latin1_General_CI_AS NULL,
	TemplateDirectory nvarchar(255) COLLATE Latin1_General_CI_AS NULL,
	US_PasswordHash nvarchar(255) COLLATE Latin1_General_CI_AS NULL,
	US_AllProjects nvarchar(1) COLLATE Latin1_General_CI_AS NULL,
	US_SampleStateChange nvarchar(1) COLLATE Latin1_General_CI_AS NULL,
	CONSTRAINT GWB_Users_PK PRIMARY KEY (US_LoginName)
);


-- db_name.dbo.GWB_ValueMarkers definition

-- Drop table

-- DROP TABLE db_name.dbo.GWB_ValueMarkers;

CREATE TABLE db_name.dbo.GWB_ValueMarkers (
	Marker nvarchar(1) COLLATE Latin1_General_CI_AS NOT NULL,
	MarkerText nvarchar(50) COLLATE Latin1_General_CI_AS NULL,
	Color int NULL,
	ID int IDENTITY(1,1) NOT NULL,
	Gww nchar(1) COLLATE Latin1_General_CI_AS DEFAULT '-' NULL,
	GwwTransferDate smalldatetime NULL,
	HasFlag nchar(1) COLLATE Latin1_General_CI_AS DEFAULT '-' NULL,
	FlagDefinition text COLLATE Latin1_General_CI_AS NULL,
	FlagPreview image NULL,
	CONSTRAINT GWB_ValueMarkers_PK PRIMARY KEY (Marker)
);


-- db_name.dbo.GWB_ValvePosition definition

-- Drop table

-- DROP TABLE db_name.dbo.GWB_ValvePosition;

CREATE TABLE db_name.dbo.GWB_ValvePosition (
	ID int NOT NULL,
	Valve_ID int NOT NULL,
	Date_Time smalldatetime NULL,
	ValvePosition int NULL,
	MaxValvePosition int NULL,
	CONSTRAINT GWB_ValvePosition_PK PRIMARY KEY (ID)
);


-- db_name.dbo.GWB_ValveTypeCat definition

-- Drop table

-- DROP TABLE db_name.dbo.GWB_ValveTypeCat;

CREATE TABLE db_name.dbo.GWB_ValveTypeCat (
	ID int NOT NULL,
	ItemName nvarchar(50) COLLATE Latin1_General_CI_AS NOT NULL,
	CONSTRAINT GWB_ValveTypeCat_PK PRIMARY KEY (ID)
);


-- db_name.dbo.GWB_Valves definition

-- Drop table

-- DROP TABLE db_name.dbo.GWB_Valves;

CREATE TABLE db_name.dbo.GWB_Valves (
	ID int NOT NULL,
	Object_ID int NOT NULL,
	Elevation float NULL,
	Diameter int NULL,
	Type_ID int NULL,
	MaxPosition int NULL,
	Description nvarchar(50) COLLATE Latin1_General_CI_AS NULL,
	CONSTRAINT GWB_Valves_PK PRIMARY KEY (ID)
);


-- db_name.dbo.GWB_Version definition

-- Drop table

-- DROP TABLE db_name.dbo.GWB_Version;

CREATE TABLE db_name.dbo.GWB_Version (
	Version nvarchar(10) COLLATE Latin1_General_CI_AS NULL,
	Version7 nvarchar(10) COLLATE Latin1_General_CI_AS NULL,
	Version8 nvarchar(10) COLLATE Latin1_General_CI_AS NULL,
	BackupDate smalldatetime NULL,
	Version9 nvarchar(10) COLLATE Latin1_General_CI_AS NULL
);


-- db_name.dbo.GWB_VirtualWells definition

-- Drop table

-- DROP TABLE db_name.dbo.GWB_VirtualWells;

CREATE TABLE db_name.dbo.GWB_VirtualWells (
	ID int NOT NULL,
	StationName nvarchar(20) COLLATE Latin1_General_CI_AS NULL,
	ReferenceStation_ID int NOT NULL,
	X float NULL,
	Y float NULL,
	Z float NULL,
	TimeLag smallint NULL,
	Shift float NULL,
	IsAbsolute char(1) COLLATE Latin1_General_CI_AS DEFAULT 'N' NULL,
	IsActive char(1) COLLATE Latin1_General_CI_AS DEFAULT 'Y' NULL,
	CreatedBy nvarchar(20) COLLATE Latin1_General_CI_AS NULL,
	Comments nvarchar(255) COLLATE Latin1_General_CI_AS NULL,
	Symbol int NULL,
	UTM_East float NULL,
	UTM_North float NULL,
	CONSTRAINT GWB_VirtualWells_PK PRIMARY KEY (ID)
);


-- db_name.dbo.GWB_WStand definition

-- Drop table

-- DROP TABLE db_name.dbo.GWB_WStand;

CREATE TABLE db_name.dbo.GWB_WStand (
	ID int NOT NULL,
	MesstellenID int NOT NULL,
	DatumZeit smalldatetime NOT NULL,
	Wasserstand float NULL,
	BezugMP char(1) COLLATE Latin1_General_CI_AS DEFAULT 'Y' NULL,
	Quality char(1) COLLATE Latin1_General_CI_AS DEFAULT '+' NULL,
	Person_ID int NULL,
	Import_ID int NULL,
	DataType int DEFAULT 0 NULL,
	Level_SL float NULL,
	LoggedDepth float NULL,
	LoggedDepth_SL float NULL,
	CONSTRAINT GWB_WStand_PK PRIMARY KEY (ID)
);
 CREATE UNIQUE NONCLUSTERED INDEX GWB_WStand_idx1 ON db_name.dbo.GWB_WStand (  MesstellenID ASC  , DatumZeit ASC  )  
	 WITH (  PAD_INDEX = OFF ,FILLFACTOR = 100  ,SORT_IN_TEMPDB = OFF , IGNORE_DUP_KEY = OFF , STATISTICS_NORECOMPUTE = OFF , ONLINE = OFF , ALLOW_ROW_LOCKS = ON , ALLOW_PAGE_LOCKS = ON  )
	 ON [PRIMARY ] ;


-- db_name.dbo.GWB_Wasserrecht definition

-- Drop table

-- DROP TABLE db_name.dbo.GWB_Wasserrecht;

CREATE TABLE db_name.dbo.GWB_Wasserrecht (
	ID int NOT NULL,
	Zuord smallint NULL,
	Zuord_ID int NULL,
	E_a int NULL,
	E_m int NULL,
	E_dm int NULL,
	E_dd int NULL,
	E_h int NULL,
	Prob_Int nvarchar(35) COLLATE Latin1_General_CI_AS NULL,
	Art smallint NULL,
	Anfang smalldatetime NULL,
	Ende smalldatetime NULL,
	AZ1 nvarchar(25) COLLATE Latin1_General_CI_AS NULL,
	AZ2 nvarchar(25) COLLATE Latin1_General_CI_AS NULL,
	Bemerk ntext COLLATE Latin1_General_CI_AS NULL,
	Neben ntext COLLATE Latin1_General_CI_AS NULL,
	Zweck nvarchar(30) COLLATE Latin1_General_CI_AS NULL,
	dat_l_ae smalldatetime NULL,
	CONSTRAINT GWB_Wasserrecht_PK PRIMARY KEY (ID)
);


-- db_name.dbo.GWB_WaterQuantity definition

-- Drop table

-- DROP TABLE db_name.dbo.GWB_WaterQuantity;

CREATE TABLE db_name.dbo.GWB_WaterQuantity (
	Org_ID int NOT NULL,
	[Year] smallint NOT NULL,
	GroundWater float NULL,
	SourceWater float NULL,
	SurfaceWater float NULL,
	ExternalWater float NULL,
	CONSTRAINT GWB_WaterQuantity_PK PRIMARY KEY (Org_ID,[Year])
);


-- db_name.dbo.GWB_WaterTypeCat definition

-- Drop table

-- DROP TABLE db_name.dbo.GWB_WaterTypeCat;

CREATE TABLE db_name.dbo.GWB_WaterTypeCat (
	ID int NOT NULL,
	ItemName nvarchar(50) COLLATE Latin1_General_CI_AS NOT NULL,
	CONSTRAINT GWB_WaterTypeCat_PK PRIMARY KEY (ID)
);


-- db_name.dbo.GWB_WellGeology definition

-- Drop table

-- DROP TABLE db_name.dbo.GWB_WellGeology;

CREATE TABLE db_name.dbo.GWB_WellGeology (
	ID int NOT NULL,
	Well_ID int NULL,
	Geology_ID int NULL,
	DepthToBase float NULL,
	Deeper nvarchar(1) COLLATE Latin1_General_CI_AS NULL,
	CONSTRAINT GWB_WellGeology_PK PRIMARY KEY (ID)
);


-- db_name.dbo.GWB_WellProperties definition

-- Drop table

-- DROP TABLE db_name.dbo.GWB_WellProperties;

CREATE TABLE db_name.dbo.GWB_WellProperties (
	ID int NOT NULL,
	Property_Name nvarchar(50) COLLATE Latin1_General_CI_AS NOT NULL,
	Property_Key nvarchar(20) COLLATE Latin1_General_CI_AS NULL,
	UseCatalog int NULL,
	CONSTRAINT GWB_WellProperties_PK PRIMARY KEY (ID)
);


-- db_name.dbo.GWB_WellProperties_Wells definition

-- Drop table

-- DROP TABLE db_name.dbo.GWB_WellProperties_Wells;

CREATE TABLE db_name.dbo.GWB_WellProperties_Wells (
	Property_ID int NOT NULL,
	Well_ID int NOT NULL,
	PropertyText varchar(255) COLLATE Latin1_General_CI_AS NULL,
	PropertyDate smalldatetime NULL,
	CONSTRAINT GWB_WellProps__Wells_PK PRIMARY KEY (Property_ID,Well_ID)
);


-- db_name.dbo.GWB_WellPumpRates definition

-- Drop table

-- DROP TABLE db_name.dbo.GWB_WellPumpRates;

CREATE TABLE db_name.dbo.GWB_WellPumpRates (
	ID int NOT NULL,
	Well_ID int NOT NULL,
	StartDate smalldatetime NULL,
	EndDate smalldatetime NULL,
	PumpRate float NULL,
	PumpUnit nvarchar(1) COLLATE Latin1_General_CI_AS NULL,
	CONSTRAINT GWB_WellPumpRates_PK PRIMARY KEY (ID)
);


-- db_name.dbo.GWB_WellStatusCat definition

-- Drop table

-- DROP TABLE db_name.dbo.GWB_WellStatusCat;

CREATE TABLE db_name.dbo.GWB_WellStatusCat (
	ID int NOT NULL,
	StatusName nvarchar(50) COLLATE Latin1_General_CI_AS NULL,
	CONSTRAINT GWB_WellStatusCat_PK PRIMARY KEY (ID)
);


-- db_name.dbo.GWB_WellStatusHistory definition

-- Drop table

-- DROP TABLE db_name.dbo.GWB_WellStatusHistory;

CREATE TABLE db_name.dbo.GWB_WellStatusHistory (
	ID int NOT NULL,
	Well_ID int NOT NULL,
	Status_ID int NOT NULL,
	StatusDate smalldatetime NOT NULL,
	StatusCommentText nvarchar(100) COLLATE Latin1_General_CI_AS NULL,
	CONSTRAINT GWB_WellStatusHistory_PK PRIMARY KEY (ID)
);


-- db_name.dbo.GWB_WellStdToDoCategories definition

-- Drop table

-- DROP TABLE db_name.dbo.GWB_WellStdToDoCategories;

CREATE TABLE db_name.dbo.GWB_WellStdToDoCategories (
	Well_ID int NOT NULL,
	Category_ID int NOT NULL,
	RepeatMonths int NULL,
	CONSTRAINT GWB_WellStdToDoCategories_PK PRIMARY KEY (Well_ID,Category_ID)
);


-- db_name.dbo.GWB_WellToDoList definition

-- Drop table

-- DROP TABLE db_name.dbo.GWB_WellToDoList;

CREATE TABLE db_name.dbo.GWB_WellToDoList (
	ID int NOT NULL,
	Well_ID int NULL,
	Category_ID int NULL,
	Description nvarchar(255) COLLATE Latin1_General_CI_AS NULL,
	CreateDate smalldatetime NULL,
	ToDoUntil smalldatetime NULL,
	User_ID int NULL,
	DoneDate smalldatetime NULL,
	DoneComment nvarchar(255) COLLATE Latin1_General_CI_AS NULL,
	DoneUser_ID int NULL,
	SAP_NotifyNumber nvarchar(12) COLLATE Latin1_General_CI_AS NULL,
	SAP_OrderNumber nvarchar(12) COLLATE Latin1_General_CI_AS NULL,
	SAP_Status nvarchar(10) COLLATE Latin1_General_CI_AS NULL,
	Status int NULL,
	CONSTRAINT GWB_WellToDoList_PK PRIMARY KEY (ID)
);


-- db_name.dbo.GWB_WellToDoListSAP_ERR definition

-- Drop table

-- DROP TABLE db_name.dbo.GWB_WellToDoListSAP_ERR;

CREATE TABLE db_name.dbo.GWB_WellToDoListSAP_ERR (
	GWB_ID int NOT NULL,
	[TYPE] nvarchar(1) COLLATE Latin1_General_CI_AS NOT NULL,
	ID nvarchar(20) COLLATE Latin1_General_CI_AS NULL,
	NUMBER nvarchar(3) COLLATE Latin1_General_CI_AS NULL,
	MESSAGE nvarchar(220) COLLATE Latin1_General_CI_AS NULL,
	LOG_NO nvarchar(20) COLLATE Latin1_General_CI_AS NULL,
	LOG_MSG_NO nvarchar(6) COLLATE Latin1_General_CI_AS NULL,
	MESSAGE_V1 nvarchar(50) COLLATE Latin1_General_CI_AS NULL,
	MESSAGE_V2 nvarchar(50) COLLATE Latin1_General_CI_AS NULL,
	MESSAGE_V3 nvarchar(50) COLLATE Latin1_General_CI_AS NULL,
	MESSAGE_V4 nvarchar(50) COLLATE Latin1_General_CI_AS NULL,
	[PARAMETER] nvarchar(32) COLLATE Latin1_General_CI_AS NULL,
	[ROW] int NULL,
	FIELD nvarchar(30) COLLATE Latin1_General_CI_AS NULL,
	[SYSTEM] nvarchar(10) COLLATE Latin1_General_CI_AS NULL,
	MESSAGE_DATE smalldatetime DEFAULT getdate() NULL
);


-- db_name.dbo.GWB_Wells_Projects definition

-- Drop table

-- DROP TABLE db_name.dbo.GWB_Wells_Projects;

CREATE TABLE db_name.dbo.GWB_Wells_Projects (
	Well_ID int NOT NULL,
	Project_ID int NOT NULL,
	CONSTRAINT GWB_Wells_Projects_PK PRIMARY KEY (Well_ID,Project_ID)
);


-- db_name.dbo.GWC_WellAquifers definition

-- Drop table

-- DROP TABLE db_name.dbo.GWC_WellAquifers;

CREATE TABLE db_name.dbo.GWC_WellAquifers (
	ID int NOT NULL,
	OrgID int NULL,
	Name nvarchar(50) COLLATE Latin1_General_CI_AS NOT NULL,
	SeqNr int DEFAULT 32000 NULL,
	SymbolFileName nvarchar(32) COLLATE Latin1_General_CI_AS NULL,
	SymbolDefinition nvarchar(128) COLLATE Latin1_General_CI_AS NULL,
	Gww nchar(1) COLLATE Latin1_General_CI_AS DEFAULT '-' NULL,
	GwwFileDate smalldatetime NULL,
	CONSTRAINT PK_GWC_WellAquifers PRIMARY KEY (ID)
);


-- db_name.dbo.GWC_WellCategories definition

-- Drop table

-- DROP TABLE db_name.dbo.GWC_WellCategories;

CREATE TABLE db_name.dbo.GWC_WellCategories (
	Type_ID int NOT NULL,
	Category_ID int NOT NULL,
	Name nvarchar(128) COLLATE Latin1_General_CI_AS NOT NULL,
	SeqNr int DEFAULT 32000 NULL,
	SymbolFileName nvarchar(32) COLLATE Latin1_General_CI_AS NULL,
	SymbolDefinition nvarchar(128) COLLATE Latin1_General_CI_AS NULL,
	SymbolWidth int NULL,
	SymbolHeight int NULL,
	SymbolAnchorX int DEFAULT 0 NULL,
	SymbolAnchorY int DEFAULT 0 NULL,
	SymbolHotspot nchar(2) COLLATE Latin1_General_CI_AS DEFAULT 'CC' NULL,
	Gww nchar(1) COLLATE Latin1_General_CI_AS DEFAULT '-' NULL,
	GwwFileDate smalldatetime NULL,
	CONSTRAINT PK_GWC_WellCategories PRIMARY KEY (Type_ID,Category_ID)
);


-- db_name.dbo.GWC_WellCategory_Types definition

-- Drop table

-- DROP TABLE db_name.dbo.GWC_WellCategory_Types;

CREATE TABLE db_name.dbo.GWC_WellCategory_Types (
	ID int NOT NULL,
	TableName nvarchar(30) COLLATE Latin1_General_CI_AS NULL,
	Name nvarchar(50) COLLATE Latin1_General_CI_AS NOT NULL,
	Gww nchar(1) COLLATE Latin1_General_CI_AS DEFAULT '-' NULL,
	GwwTransferDate smalldatetime NULL,
	CONSTRAINT PK_GWC_WellCategory_Types PRIMARY KEY (ID)
);


-- db_name.dbo.GWC_WellGeology definition

-- Drop table

-- DROP TABLE db_name.dbo.GWC_WellGeology;

CREATE TABLE db_name.dbo.GWC_WellGeology (
	ID int NOT NULL,
	OrgID int NULL,
	Name nvarchar(50) COLLATE Latin1_General_CI_AS NOT NULL,
	SeqNr int DEFAULT 32000 NULL,
	SymbolFileName nvarchar(32) COLLATE Latin1_General_CI_AS NULL,
	SymbolDefinition nvarchar(128) COLLATE Latin1_General_CI_AS NULL,
	Gww nchar(1) COLLATE Latin1_General_CI_AS DEFAULT '-' NULL,
	GwwFileDate smalldatetime NULL,
	CONSTRAINT PK_GWC_WellGeology PRIMARY KEY (ID)
);


-- db_name.dbo.GWC_WellGroundOwner definition

-- Drop table

-- DROP TABLE db_name.dbo.GWC_WellGroundOwner;

CREATE TABLE db_name.dbo.GWC_WellGroundOwner (
	ID int NOT NULL,
	Name nvarchar(50) COLLATE Latin1_General_CI_AS NOT NULL,
	SeqNr int DEFAULT 32000 NULL,
	SymbolFileName nvarchar(32) COLLATE Latin1_General_CI_AS NULL,
	SymbolDefinition nvarchar(128) COLLATE Latin1_General_CI_AS NULL,
	Gww nchar(1) COLLATE Latin1_General_CI_AS DEFAULT '-' NULL,
	GwwFileDate smalldatetime NULL,
	CONSTRAINT PK_GWC_WellGroundOwner PRIMARY KEY (ID)
);


-- db_name.dbo.GWC_WellKind definition

-- Drop table

-- DROP TABLE db_name.dbo.GWC_WellKind;

CREATE TABLE db_name.dbo.GWC_WellKind (
	ID int NOT NULL,
	Name nvarchar(50) COLLATE Latin1_General_CI_AS NOT NULL,
	SeqNr int DEFAULT 32000 NULL,
	SymbolFileName nvarchar(32) COLLATE Latin1_General_CI_AS NULL,
	SymbolDefinition nvarchar(128) COLLATE Latin1_General_CI_AS NULL,
	Gww nchar(1) COLLATE Latin1_General_CI_AS DEFAULT '-' NULL,
	GwwFileDate smalldatetime NULL,
	CONSTRAINT PK_GWC_WellKind PRIMARY KEY (ID)
);


-- db_name.dbo.GWC_WellLocation definition

-- Drop table

-- DROP TABLE db_name.dbo.GWC_WellLocation;

CREATE TABLE db_name.dbo.GWC_WellLocation (
	ID int NOT NULL,
	Name nvarchar(50) COLLATE Latin1_General_CI_AS NOT NULL,
	SeqNr int DEFAULT 32000 NULL,
	SymbolFileName nvarchar(32) COLLATE Latin1_General_CI_AS NULL,
	SymbolDefinition nvarchar(128) COLLATE Latin1_General_CI_AS NULL,
	Gww nchar(1) COLLATE Latin1_General_CI_AS DEFAULT '-' NULL,
	GwwFileDate smalldatetime NULL,
	CONSTRAINT PK_GWC_WellLocation PRIMARY KEY (ID)
);


-- db_name.dbo.GWC_WellLocationFL definition

-- Drop table

-- DROP TABLE db_name.dbo.GWC_WellLocationFL;

CREATE TABLE db_name.dbo.GWC_WellLocationFL (
	ID int NOT NULL,
	Name nvarchar(50) COLLATE Latin1_General_CI_AS NOT NULL,
	SeqNr int DEFAULT 32000 NULL,
	SymbolFileName nvarchar(32) COLLATE Latin1_General_CI_AS NULL,
	SymbolDefinition nvarchar(128) COLLATE Latin1_General_CI_AS NULL,
	Gww nchar(1) COLLATE Latin1_General_CI_AS DEFAULT '-' NULL,
	GwwFileDate smalldatetime NULL,
	CONSTRAINT PK_GWC_WellLocationFL PRIMARY KEY (ID)
);


-- db_name.dbo.GWC_WellLocationFS definition

-- Drop table

-- DROP TABLE db_name.dbo.GWC_WellLocationFS;

CREATE TABLE db_name.dbo.GWC_WellLocationFS (
	ID int NOT NULL,
	Name nvarchar(50) COLLATE Latin1_General_CI_AS NOT NULL,
	SeqNr int DEFAULT 32000 NULL,
	SymbolFileName nvarchar(32) COLLATE Latin1_General_CI_AS NULL,
	SymbolDefinition nvarchar(128) COLLATE Latin1_General_CI_AS NULL,
	Gww nchar(1) COLLATE Latin1_General_CI_AS DEFAULT '-' NULL,
	GwwFileDate smalldatetime NULL,
	CONSTRAINT PK_GWC_WellLocationFS PRIMARY KEY (ID)
);


-- db_name.dbo.GWC_WellLocationGE definition

-- Drop table

-- DROP TABLE db_name.dbo.GWC_WellLocationGE;

CREATE TABLE db_name.dbo.GWC_WellLocationGE (
	ID int NOT NULL,
	Name nvarchar(50) COLLATE Latin1_General_CI_AS NOT NULL,
	SeqNr int DEFAULT 32000 NULL,
	SymbolFileName nvarchar(32) COLLATE Latin1_General_CI_AS NULL,
	SymbolDefinition nvarchar(128) COLLATE Latin1_General_CI_AS NULL,
	Gww nchar(1) COLLATE Latin1_General_CI_AS DEFAULT '-' NULL,
	GwwFileDate smalldatetime NULL,
	CONSTRAINT PK_GWC_WellLocationGE PRIMARY KEY (ID)
);


-- db_name.dbo.GWC_WellOperator definition

-- Drop table

-- DROP TABLE db_name.dbo.GWC_WellOperator;

CREATE TABLE db_name.dbo.GWC_WellOperator (
	ID int NOT NULL,
	Name nvarchar(50) COLLATE Latin1_General_CI_AS NOT NULL,
	SeqNr int DEFAULT 32000 NULL,
	SymbolFileName nvarchar(32) COLLATE Latin1_General_CI_AS NULL,
	SymbolDefinition nvarchar(128) COLLATE Latin1_General_CI_AS NULL,
	Gww nchar(1) COLLATE Latin1_General_CI_AS DEFAULT '-' NULL,
	GwwFileDate smalldatetime NULL,
	CONSTRAINT PK_GWC_WellOperator PRIMARY KEY (ID)
);


-- db_name.dbo.GWC_WellSite definition

-- Drop table

-- DROP TABLE db_name.dbo.GWC_WellSite;

CREATE TABLE db_name.dbo.GWC_WellSite (
	ID int NOT NULL,
	Name nvarchar(50) COLLATE Latin1_General_CI_AS NOT NULL,
	SeqNr int DEFAULT 32000 NULL,
	SymbolFileName nvarchar(32) COLLATE Latin1_General_CI_AS NULL,
	SymbolDefinition nvarchar(128) COLLATE Latin1_General_CI_AS NULL,
	Gww nchar(1) COLLATE Latin1_General_CI_AS DEFAULT '-' NULL,
	GwwFileDate smalldatetime NULL,
	CONSTRAINT PK_GWC_WellSite PRIMARY KEY (ID)
);


-- db_name.dbo.GWC_WellUse definition

-- Drop table

-- DROP TABLE db_name.dbo.GWC_WellUse;

CREATE TABLE db_name.dbo.GWC_WellUse (
	ID int NOT NULL,
	Name nvarchar(50) COLLATE Latin1_General_CI_AS NOT NULL,
	SeqNr int DEFAULT 32000 NULL,
	SymbolFileName nvarchar(32) COLLATE Latin1_General_CI_AS NULL,
	SymbolDefinition nvarchar(128) COLLATE Latin1_General_CI_AS NULL,
	Gww nchar(1) COLLATE Latin1_General_CI_AS DEFAULT '-' NULL,
	GwwFileDate smalldatetime NULL,
	CONSTRAINT PK_GWC_WellUse PRIMARY KEY (ID)
);


-- db_name.dbo.GWM_Depths definition

-- Drop table

-- DROP TABLE db_name.dbo.GWM_Depths;

CREATE TABLE db_name.dbo.GWM_Depths (
	Well_ID int NOT NULL,
	[Depth] float NOT NULL,
	CONSTRAINT GWB_Depths_PK PRIMARY KEY (Well_ID,[Depth])
);


-- db_name.dbo.GWM_Persons definition

-- Drop table

-- DROP TABLE db_name.dbo.GWM_Persons;

CREATE TABLE db_name.dbo.GWM_Persons (
	Person_ID int NOT NULL,
	Person_Name nvarchar(20) COLLATE Latin1_General_CI_AS NULL,
	Person_PIN nvarchar(4) COLLATE Latin1_General_CI_AS NULL,
	AllowSeeLastValue char(1) COLLATE Latin1_General_CI_AS NULL,
	AllowModifyWellData char(1) COLLATE Latin1_General_CI_AS NULL,
	PersonType nvarchar(1) COLLATE Latin1_General_CI_AS NULL,
	SAP_Key nvarchar(50) COLLATE Latin1_General_CI_AS NULL,
	CONSTRAINT GWB_Persons_PK PRIMARY KEY (Person_ID)
);


-- db_name.dbo.GWM_PictureCategoriesCat definition

-- Drop table

-- DROP TABLE db_name.dbo.GWM_PictureCategoriesCat;

CREATE TABLE db_name.dbo.GWM_PictureCategoriesCat (
	ID int NOT NULL,
	PictureCategory nvarchar(50) COLLATE Latin1_General_CI_AS NOT NULL,
	CONSTRAINT GWM_PictureCategoriesCat_PK PRIMARY KEY (ID)
);


-- db_name.dbo.GWM_Routes definition

-- Drop table

-- DROP TABLE db_name.dbo.GWM_Routes;

CREATE TABLE db_name.dbo.GWM_Routes (
	Route_ID int NOT NULL,
	Route_Name nvarchar(50) COLLATE Latin1_General_CI_AS NULL,
	Route_Type nvarchar(1) COLLATE Latin1_General_CI_AS NULL,
	Person1_ID int NULL,
	Person2_ID int NULL,
	CONSTRAINT GWB_Routes_PK PRIMARY KEY (Route_ID)
);


-- db_name.dbo.GWM_Routes_Wells definition

-- Drop table

-- DROP TABLE db_name.dbo.GWM_Routes_Wells;

CREATE TABLE db_name.dbo.GWM_Routes_Wells (
	Route_ID int NOT NULL,
	Well_ID int NOT NULL,
	SeqNr int NULL,
	CONSTRAINT GWB_Routes_Wells_PK PRIMARY KEY (Route_ID,Well_ID)
);


-- db_name.dbo.GWW_DataStatus definition

-- Drop table

-- DROP TABLE db_name.dbo.GWW_DataStatus;

CREATE TABLE db_name.dbo.GWW_DataStatus (
	MSID int NOT NULL,
	DataType int NOT NULL,
	ParamId int NOT NULL,
	Count_ int NULL,
	MinDate smalldatetime NULL,
	MaxDate smalldatetime NULL,
	CONSTRAINT PK_GWW_DataStatus PRIMARY KEY (MSID,DataType,ParamId)
);


-- db_name.dbo.GWW_Layers definition

-- Drop table

-- DROP TABLE db_name.dbo.GWW_Layers;

CREATE TABLE db_name.dbo.GWW_Layers (
	ID int NOT NULL,
	FileName nvarchar(255) COLLATE Latin1_General_CI_AS NOT NULL,
	Directory nvarchar(255) COLLATE Latin1_General_CI_AS NOT NULL,
	LayerClass int NULL,
	Geotype nvarchar(20) COLLATE Latin1_General_CI_AS NULL,
	DisplayName nvarchar(128) COLLATE Latin1_General_CI_AS NULL,
	Description text COLLATE Latin1_General_CI_AS NULL,
	Definition text COLLATE Latin1_General_CI_AS NULL,
	Gww nchar(1) COLLATE Latin1_General_CI_AS DEFAULT '-' NULL,
	GwwFileDate smalldatetime NULL,
	SortNo int DEFAULT 32000 NULL,
	CONSTRAINT PK_GWW_Layers PRIMARY KEY (ID)
);


-- db_name.dbo.GWW_MapServices definition

-- Drop table

-- DROP TABLE db_name.dbo.GWW_MapServices;

CREATE TABLE db_name.dbo.GWW_MapServices (
	ID int NOT NULL,
	Name nvarchar(128) COLLATE Latin1_General_CI_AS NULL,
	Title nvarchar(128) COLLATE Latin1_General_CI_AS NULL,
	ServiceType nvarchar(32) COLLATE Latin1_General_CI_AS NULL,
	ServiceVersion nvarchar(16) COLLATE Latin1_General_CI_AS NULL,
	DisplayTitle nvarchar(128) COLLATE Latin1_General_CI_AS NULL,
	Abstract text COLLATE Latin1_General_CI_AS NULL,
	URL text COLLATE Latin1_General_CI_AS NULL,
	ProviderName nvarchar(128) COLLATE Latin1_General_CI_AS NULL,
	ProviderURL text COLLATE Latin1_General_CI_AS NULL,
	SourceName nvarchar(128) COLLATE Latin1_General_CI_AS NULL,
	SourceURL text COLLATE Latin1_General_CI_AS NULL,
	Fees text COLLATE Latin1_General_CI_AS NULL,
	AccessConstraints text COLLATE Latin1_General_CI_AS NULL,
	Keywords text COLLATE Latin1_General_CI_AS NULL,
	Contact text COLLATE Latin1_General_CI_AS NULL,
	Attribution text COLLATE Latin1_General_CI_AS NULL,
	AuthorityUrlName nvarchar(64) COLLATE Latin1_General_CI_AS NULL,
	AuthorityUrlHref text COLLATE Latin1_General_CI_AS NULL,
	IdentifierAuthority nvarchar(64) COLLATE Latin1_General_CI_AS NULL,
	IdentifierUrl text COLLATE Latin1_General_CI_AS NULL,
	UserName nvarchar(64) COLLATE Latin1_General_CI_AS NULL,
	UserPassword nvarchar(64) COLLATE Latin1_General_CI_AS NULL,
	SortNo int DEFAULT 32000 NULL,
	CONSTRAINT PK_GWW_MapServices PRIMARY KEY (ID)
);


-- db_name.dbo.GWW_Maps definition

-- Drop table

-- DROP TABLE db_name.dbo.GWW_Maps;

CREATE TABLE db_name.dbo.GWW_Maps (
	ID int NOT NULL,
	DisplayName nvarchar(128) COLLATE Latin1_General_CI_AS NULL,
	Name nvarchar(128) COLLATE Latin1_General_CI_AS NULL,
	Title nvarchar(128) COLLATE Latin1_General_CI_AS NULL,
	URL text COLLATE Latin1_General_CI_AS NULL,
	ProviderName nvarchar(128) COLLATE Latin1_General_CI_AS NULL,
	ProviderUrl text COLLATE Latin1_General_CI_AS NULL,
	SourceName nvarchar(128) COLLATE Latin1_General_CI_AS NULL,
	SourceURL text COLLATE Latin1_General_CI_AS NULL,
	CRS nvarchar(16) COLLATE Latin1_General_CI_AS NULL,
	CrsName nvarchar(64) COLLATE Latin1_General_CI_AS NULL,
	AvailableCrs text COLLATE Latin1_General_CI_AS NULL,
	Abstract text COLLATE Latin1_General_CI_AS NULL,
	ServiceType nvarchar(32) COLLATE Latin1_General_CI_AS NULL,
	ServiceVersion nvarchar(16) COLLATE Latin1_General_CI_AS NULL,
	JsLayerDef text COLLATE Latin1_General_CI_AS NULL,
	Gww nchar(1) COLLATE Latin1_General_CI_AS DEFAULT '-' NULL,
	GwwTransferDate smalldatetime NULL,
	SortNo int DEFAULT 32000 NULL,
	IsOverlay nvarchar(1) COLLATE Latin1_General_CI_AS DEFAULT '-' NULL,
	CONSTRAINT PK_GWW_Maps PRIMARY KEY (ID)
);


-- db_name.dbo.GWW_Profiles definition

-- Drop table

-- DROP TABLE db_name.dbo.GWW_Profiles;

CREATE TABLE db_name.dbo.GWW_Profiles (
	ID int NOT NULL,
	FileName nvarchar(255) COLLATE Latin1_General_CI_AS NOT NULL,
	Directory nvarchar(255) COLLATE Latin1_General_CI_AS NOT NULL,
	[Type] int NULL,
	DisplayName nvarchar(128) COLLATE Latin1_General_CI_AS NULL,
	Description text COLLATE Latin1_General_CI_AS NULL,
	Definition text COLLATE Latin1_General_CI_AS NULL,
	Gww nchar(1) COLLATE Latin1_General_CI_AS DEFAULT '-' NULL,
	GwwFileDate smalldatetime NULL,
	SortNo int DEFAULT 32000 NULL,
	CONSTRAINT PK_GWW_Profiles PRIMARY KEY (ID)
);


-- db_name.dbo.GWW_WebConfig definition

-- Drop table

-- DROP TABLE db_name.dbo.GWW_WebConfig;

CREATE TABLE db_name.dbo.GWW_WebConfig (
	ID int NOT NULL,
	WebArea_ID int NULL,
	WebOrg_ID int NULL,
	WebOrg_Krz nvarchar(20) COLLATE Latin1_General_CI_AS NULL,
	UserName nvarchar(50) COLLATE Latin1_General_CI_AS NULL,
	UserPassword nvarchar(50) COLLATE Latin1_General_CI_AS NULL,
	WebDomain nvarchar(50) COLLATE Latin1_General_CI_AS NULL,
	[Path] nvarchar(50) COLLATE Latin1_General_CI_AS NULL,
	RequestScript nvarchar(50) COLLATE Latin1_General_CI_AS NULL,
	Port int NULL,
	SSL nchar(1) COLLATE Latin1_General_CI_AS DEFAULT '-' NULL,
	ConnectTimeout int DEFAULT 5 NULL,
	ReadTimeout int DEFAULT 20 NULL,
	HTTP_ParamsOk nchar(1) COLLATE Latin1_General_CI_AS DEFAULT '-' NULL,
	FTP_User nvarchar(50) COLLATE Latin1_General_CI_AS NULL,
	FTP_Password nvarchar(50) COLLATE Latin1_General_CI_AS NULL,
	FTP_Server nvarchar(50) COLLATE Latin1_General_CI_AS NULL,
	FTP_Path nvarchar(50) COLLATE Latin1_General_CI_AS NULL,
	FTP_Port int NULL,
	FTP_SSL nchar(1) COLLATE Latin1_General_CI_AS DEFAULT '-' NULL,
	FTP_PassiveMode nchar(1) COLLATE Latin1_General_CI_AS DEFAULT '+' NULL,
	FTP_ConnectTimeout int DEFAULT 6 NULL,
	FTP_ReadTimeout int DEFAULT 60 NULL,
	FTP_ParamsOk nchar(1) COLLATE Latin1_General_CI_AS DEFAULT '-' NULL,
	Proxy_User nvarchar(50) COLLATE Latin1_General_CI_AS NULL,
	Proxy_Password nvarchar(50) COLLATE Latin1_General_CI_AS NULL,
	Proxy_Server nvarchar(50) COLLATE Latin1_General_CI_AS NULL,
	Proxy_Port int NULL,
	FTPProxy_User nvarchar(50) COLLATE Latin1_General_CI_AS NULL,
	FTPProxy_Password nvarchar(50) COLLATE Latin1_General_CI_AS NULL,
	FTPProxy_Server nvarchar(50) COLLATE Latin1_General_CI_AS NULL,
	FTPProxy_Port int NULL,
	UsageFotos nchar(1) COLLATE Latin1_General_CI_AS DEFAULT '+' NULL,
	UsageWellDocuments nchar(1) COLLATE Latin1_General_CI_AS DEFAULT '+' NULL,
	UsageLevels int DEFAULT 2 NULL,
	UsageAnanlyses int DEFAULT 2 NULL,
	UsageLogger int DEFAULT 2 NULL,
	UsageRates int DEFAULT 2 NULL,
	UsagePrecipitate int DEFAULT 2 NULL,
	UsageClimate int DEFAULT 2 NULL,
	UsageAnaMediumWater nchar(1) COLLATE Latin1_General_CI_AS DEFAULT '+' NULL,
	UsageAnaMediumSolid nchar(1) COLLATE Latin1_General_CI_AS DEFAULT '-' NULL,
	UsageAnaMediumEluat nchar(1) COLLATE Latin1_General_CI_AS DEFAULT '-' NULL,
	UsageAnaMediumAir nchar(1) COLLATE Latin1_General_CI_AS DEFAULT '-' NULL,
	UsageCategories nchar(1) COLLATE Latin1_General_CI_AS DEFAULT '+' NULL,
	UsageSubProjects nchar(1) COLLATE Latin1_General_CI_AS DEFAULT '+' NULL,
	UsageSynonymes nchar(1) COLLATE Latin1_General_CI_AS DEFAULT '+' NULL,
	UsageLayers nchar(1) COLLATE Latin1_General_CI_AS DEFAULT '+' NULL,
	UsageProfiles nchar(1) COLLATE Latin1_General_CI_AS DEFAULT '+' NULL,
	UsageProjectDocument nchar(1) COLLATE Latin1_General_CI_AS DEFAULT '+' NULL,
	GwbEpsg nvarchar(16) COLLATE Latin1_General_CI_AS NULL,
	GwbEpsgName nvarchar(128) COLLATE Latin1_General_CI_AS NULL,
	GwbUtmEpsg nvarchar(16) COLLATE Latin1_General_CI_AS NULL,
	GwbUtmEpsgName nvarchar(128) COLLATE Latin1_General_CI_AS NULL,
	GwwPreferedEpsgTyp int NULL,
	GwwPreferedEpsg nvarchar(16) COLLATE Latin1_General_CI_AS NULL,
	GwwPreferedEpsgName nvarchar(128) COLLATE Latin1_General_CI_AS NULL,
	ProveValueListNo int NULL,
	WarningValueListNo int NULL,
	LogoFile nvarchar(255) COLLATE Latin1_General_CI_AS NULL,
	FTPProxy_Http nchar(1) COLLATE Latin1_General_CI_AS DEFAULT '-' NULL,
	FTPProxy_HttpAuthMethod nvarchar(20) COLLATE Latin1_General_CI_AS NULL,
	PreferedMapID int NULL,
	LoginLogoFile nvarchar(255) COLLATE Latin1_General_CI_AS NULL,
	LogoPosition nvarchar(32) COLLATE Latin1_General_CI_AS DEFAULT 'legBottom' NULL,
	UsageValueMarkers nchar(1) COLLATE Latin1_General_CI_AS DEFAULT '-' NULL,
	UsageLevelComments nchar(1) COLLATE Latin1_General_CI_AS DEFAULT '-' NULL,
	LogoImg image NULL,
	LoginLogoImg image NULL,
	LevelCommentsHasFlag nchar(1) COLLATE Latin1_General_CI_AS DEFAULT '-' NULL,
	LevelBglNegative nchar(1) COLLATE Latin1_General_CI_AS DEFAULT '-' NULL,
	LevelCommentsFlagDefinition text COLLATE Latin1_General_CI_AS NULL,
	LevelCommentsFlagPreview image NULL,
	CONSTRAINT PK_GWW_WebConfig PRIMARY KEY (ID)
);


-- db_name.dbo.GWW_WellDataCounts definition

-- Drop table

-- DROP TABLE db_name.dbo.GWW_WellDataCounts;

CREATE TABLE db_name.dbo.GWW_WellDataCounts (
	MSID int NOT NULL,
	CountLv int NULL,
	CountAn int NULL,
	CountLg int NULL,
	CountRt int NULL,
	CountRn int NULL,
	CountCl int NULL,
	CountDo int NULL,
	CONSTRAINT PK_GWW_WellDataCounts PRIMARY KEY (MSID)
);


-- db_name.dbo.RST_AppConfig definition

-- Drop table

-- DROP TABLE db_name.dbo.RST_AppConfig;

CREATE TABLE db_name.dbo.RST_AppConfig (
	Mandant_ID int NOT NULL,
	Module_ID nvarchar(16) COLLATE Latin1_General_CI_AS NOT NULL,
	Key_ nvarchar(100) COLLATE Latin1_General_CI_AS NOT NULL,
	Value_I int NULL,
	Value_F float NULL,
	Value_S text COLLATE Latin1_General_CI_AS NULL,
	Value_DT date NULL,
	CONSTRAINT PK_RST_AppConfig PRIMARY KEY (Mandant_ID,Module_ID,Key_)
);


-- db_name.dbo.RST_DbVersion definition

-- Drop table

-- DROP TABLE db_name.dbo.RST_DbVersion;

CREATE TABLE db_name.dbo.RST_DbVersion (
	Mandant_ID int NOT NULL,
	Module_ID nvarchar(32) COLLATE Latin1_General_CI_AS NOT NULL,
	Version int NULL,
	CONSTRAINT PK_RST_DbVersion PRIMARY KEY (Mandant_ID,Module_ID)
);


-- db_name.dbo.RST_Synchronize definition

-- Drop table

-- DROP TABLE db_name.dbo.RST_Synchronize;

CREATE TABLE db_name.dbo.RST_Synchronize (
	Mandant_ID int NOT NULL,
	Module_ID nvarchar(16) COLLATE Latin1_General_CI_AS NOT NULL,
	Action_ nvarchar(32) COLLATE Latin1_General_CI_AS NOT NULL,
	SessionGUID nvarchar(70) COLLATE Latin1_General_CI_AS NULL,
	TimeStamp_ smalldatetime NULL,
	Value_I int NULL,
	Value_S nvarchar(255) COLLATE Latin1_General_CI_AS NULL,
	CONSTRAINT PK_RST_Synchronize PRIMARY KEY (Mandant_ID,Module_ID,Action_)
);


-- db_name.dbo.RepItems definition

-- Drop table

-- DROP TABLE db_name.dbo.RepItems;

CREATE TABLE db_name.dbo.RepItems (
	Id int NOT NULL,
	ReportType int NOT NULL,
	Name nvarchar(50) COLLATE Latin1_General_CI_AS NOT NULL,
	[Size] int NULL,
	Template image NULL,
	Project nvarchar(50) COLLATE Latin1_General_CI_AS NULL,
	CONSTRAINT RepItems_PK PRIMARY KEY (Id)
);


-- db_name.dbo.GPD_MsStamm definition

-- Drop table

-- DROP TABLE db_name.dbo.GPD_MsStamm;

CREATE TABLE db_name.dbo.GPD_MsStamm (
	MSID int NOT NULL,
	STM_LOCID int NULL,
	STM_BohrID int NULL,
	STM_Status int NULL,
	STM_Vertraulichkeit int NULL,
	STM_BohrArt int NULL,
	STM_BohrVerf int NULL,
	STM_BohrZweck int NULL,
	STM_KoordFind int NULL,
	STM_KoordSys int NULL,
	STM_EndRechtwert float NULL,
	STM_EndHochwert float NULL,
	STM_BohrAnsatzHoehe float NULL,
	STM_BohrEndHoehe float NULL,
	STM_HFind int NULL,
	STM_HSys int NULL,
	STM_Aktenzeichen nvarchar(64) COLLATE Latin1_General_CI_AS NULL,
	STM_ArchivFach int NULL,
	STM_ARNUM int NULL,
	STM_TiefBArchivNr int NULL,
	STM_TK5 int NULL,
	STM_Land int NULL,
	STM_Bundesland int NULL,
	STM_Landkreis int NULL,
	STM_Regierungsbezirk int NULL,
	STM_Behoerde int NULL,
	STM_Auftraggeber int NULL,
	STM_FrmBaustelle int NULL,
	STM_FrmBohrung int NULL,
	STM_FrmAusbau int NULL,
	STM_FrmKellerAusbau int NULL,
	STM_BetreuendesBuero int NULL,
	STM_DtmBohrBeginn smalldatetime NULL,
	STM_DtmBohrEnde smalldatetime NULL,
	STM_DtmBohrProt smalldatetime NULL,
	STM_DtmDVErfass smalldatetime NULL,
	STM_DtmAntrag smalldatetime NULL,
	STM_DtmGenehmigung smalldatetime NULL,
	STM_DtmBPlatzEinrichten smalldatetime NULL,
	STM_DtmBPlatzRaeumen smalldatetime NULL,
	STM_DtmImport smalldatetime NULL,
	STM_BearbeiterBohr int NULL,
	STM_BearbeiterGeol int NULL,
	STM_BearbeiterHydro int NULL,
	STM_Bohrmeister int NULL,
	STM_DVErfasser nvarchar(80) COLLATE Latin1_General_CI_AS NULL,
	STM_Bauleiter int NULL,
	STM_DATHINW nvarchar(48) COLLATE Latin1_General_CI_AS NULL,
	STM_Bemerkungen nvarchar(254) COLLATE Latin1_General_CI_AS NULL,
	STM_HydAufschlussNr int NULL,
	STM_MSArt int NULL,
	STM_StratigrafieListe int NULL,
	STM_PTFileYN nvarchar(1) COLLATE Latin1_General_CI_AS NULL,
	STM_IsSepImport nvarchar(1) COLLATE Latin1_General_CI_AS NULL,
	STM_IsSep nvarchar(1) COLLATE Latin1_General_CI_AS NULL,
	STM_SepValid nvarchar(1) COLLATE Latin1_General_CI_AS NULL,
	STM_OldWellID int NULL,
	CONSTRAINT GPD_MsStamm_PK PRIMARY KEY (MSID),
	CONSTRAINT FK_GPD_MSSTAMM_1 FOREIGN KEY (MSID) REFERENCES db_name.dbo.GWB_MSStamm(ID) ON DELETE CASCADE
);


-- db_name.dbo.GPD_PackerTest definition

-- Drop table

-- DROP TABLE db_name.dbo.GPD_PackerTest;

CREATE TABLE db_name.dbo.GPD_PackerTest (
	MSID int NOT NULL,
	RECID int NOT NULL,
	PT_TestNr nvarchar(50) COLLATE Latin1_General_CI_AS NULL,
	PT_DatumZeit smalldatetime NULL,
	PT_Analysenansatz nvarchar(50) COLLATE Latin1_General_CI_AS NULL,
	PT_IntervallEnde float NULL,
	PT_IntervallAnfang float NULL,
	PT_StreckenLaenge float NULL,
	PT_Zone int NULL,
	PT_Bemerkung nvarchar(255) COLLATE Latin1_General_CI_AS NULL,
	PT_Art_T_Kf int NULL,
	PT_T float NULL,
	PT_T_ZFGolder float NULL,
	PT_Kf float NULL,
	PT_S float NULL,
	PT_Ss float NULL,
	PT_ELf float NULL,
	PT_Ph float NULL,
	PT_IntervallMitteGOK float NULL,
	PT_AnsatzHoehe float NULL,
	PT_IntervallMitteNN float NULL,
	PT_StatischerGwSpiegelGOK float NULL,
	PT_StatischerGwSpiegelNN float NULL,
	PT_ProduziertesVolumen float NULL,
	PT_GeolEinhVon int NULL,
	PT_GeolEinhBis int NULL,
	PT_GeolEinhImportErr int NULL,
	CONSTRAINT GPD_PackerTest_PK PRIMARY KEY (MSID,RECID),
	CONSTRAINT FK_GPD_PackerTest_1 FOREIGN KEY (MSID) REFERENCES db_name.dbo.GPD_MsStamm(MSID) ON DELETE CASCADE
);


-- db_name.dbo.GPD_SchichtTitel definition

-- Drop table

-- DROP TABLE db_name.dbo.GPD_SchichtTitel;

CREATE TABLE db_name.dbo.GPD_SchichtTitel (
	MSID int NOT NULL,
	RECID int NOT NULL,
	ST_IntVersion int NULL,
	ST_IntProjLeiter int NULL,
	ST_IntBearbeiter int NULL,
	ST_DtmIntBearbeitung smalldatetime NULL,
	ST_DtmIntAenderung smalldatetime NULL,
	ST_UebernahmeKennung nvarchar(50) COLLATE Latin1_General_CI_AS NULL,
	ST_OpFeldBearbeiter nvarchar(64) COLLATE Latin1_General_CI_AS NULL,
	ST_Ausw nvarchar(24) COLLATE Latin1_General_CI_AS NULL,
	ST_IntGruppe nvarchar(12) COLLATE Latin1_General_CI_AS NULL,
	ST_IntBasisVersion int NULL,
	ST_IntNeu int NULL,
	ST_IntBemerkung nvarchar(254) COLLATE Latin1_General_CI_AS NULL,
	CONSTRAINT GPD_SchichtTitel_PK PRIMARY KEY (MSID,RECID),
	CONSTRAINT FK_GPD_SchichtTitel_1 FOREIGN KEY (MSID) REFERENCES db_name.dbo.GPD_MsStamm(MSID) ON DELETE CASCADE
);


-- db_name.dbo.GPD_Schichten definition

-- Drop table

-- DROP TABLE db_name.dbo.GPD_Schichten;

CREATE TABLE db_name.dbo.GPD_Schichten (
	MSID int NOT NULL,
	SD_LAYERID int NOT NULL,
	SD_LAYERCNTR int NOT NULL,
	SD_LayerNo int NULL,
	SD_SublayerNo int NULL,
	SD_OK float NULL,
	SD_UK float NULL,
	SD_Art nvarchar(128) COLLATE Latin1_General_CI_AS NULL,
	SD_Stratigrafie nvarchar(254) COLLATE Latin1_General_CI_AS NULL,
	SD_StratigrafieID int NULL,
	SD_Petrografie nvarchar(254) COLLATE Latin1_General_CI_AS NULL,
	SD_Genese nvarchar(254) COLLATE Latin1_General_CI_AS NULL,
	SD_Farbe nvarchar(254) COLLATE Latin1_General_CI_AS NULL,
	SD_Zusatz nvarchar(254) COLLATE Latin1_General_CI_AS NULL,
	SD_Bemerkung nvarchar(128) COLLATE Latin1_General_CI_AS NULL,
	SD_BeschaffenheitBohrgut nvarchar(128) COLLATE Latin1_General_CI_AS NULL,
	SD_Bohrvorgang nvarchar(128) COLLATE Latin1_General_CI_AS NULL,
	SD_Bodengruppe nvarchar(128) COLLATE Latin1_General_CI_AS NULL,
	SD_Kalkgehalt nvarchar(128) COLLATE Latin1_General_CI_AS NULL,
	SD_IntVersion int NULL,
	SD_IntGruppe nvarchar(12) COLLATE Latin1_General_CI_AS NULL,
	SD_IntKlasse nvarchar(12) COLLATE Latin1_General_CI_AS NULL,
	SD_IntNotitz ntext COLLATE Latin1_General_CI_AS NULL,
	SD_Textur int NULL,
	SD_Kristallinitaet int NULL,
	SD_TrennflaechenFuellung int NULL,
	SD_StreichenFallen nvarchar(64) COLLATE Latin1_General_CI_AS NULL,
	SD_ErgBemerkung nvarchar(255) COLLATE Latin1_General_CI_AS NULL,
	SD_UeblicheBez nvarchar(64) COLLATE Latin1_General_CI_AS NULL,
	SD_GeolBez nvarchar(64) COLLATE Latin1_General_CI_AS NULL,
	SD_BodenKlasse int NULL,
	SD_Verwitterung int NULL,
	SD_WetZones nvarchar(64) COLLATE Latin1_General_CI_AS NULL,
	SD_Fractures nvarchar(64) COLLATE Latin1_General_CI_AS NULL,
	SD_PetroKlar nvarchar(255) COLLATE Latin1_General_CI_AS NULL,
	SD_SepPetro nvarchar(254) COLLATE Latin1_General_CI_AS NULL,
	SD_SepFarbe nvarchar(254) COLLATE Latin1_General_CI_AS NULL,
	SD_SepBeschBG nvarchar(128) COLLATE Latin1_General_CI_AS NULL,
	SD_SepBeschBV nvarchar(128) COLLATE Latin1_General_CI_AS NULL,
	SD_SepKalkGeh nvarchar(128) COLLATE Latin1_General_CI_AS NULL,
	SD_StratigrafieKrz nvarchar(64) COLLATE Latin1_General_CI_AS NULL,
	SD_ArtKlar ntext COLLATE Latin1_General_CI_AS NULL,
	SD_GeneseKlar ntext COLLATE Latin1_General_CI_AS NULL,
	SD_FarbeKlar ntext COLLATE Latin1_General_CI_AS NULL,
	SD_ZusatzKlar ntext COLLATE Latin1_General_CI_AS NULL,
	SD_BeschBGKlar ntext COLLATE Latin1_General_CI_AS NULL,
	SD_BohrvorgangKlar ntext COLLATE Latin1_General_CI_AS NULL,
	SD_BodengruppeKlar ntext COLLATE Latin1_General_CI_AS NULL,
	SD_KalkgehaltKlar ntext COLLATE Latin1_General_CI_AS NULL,
	SD_SepError int NULL,
	CONSTRAINT GPD_Schichten_PK PRIMARY KEY (MSID,SD_LAYERID,SD_LAYERCNTR),
	CONSTRAINT FK_GPD_Schichten_1 FOREIGN KEY (MSID) REFERENCES db_name.dbo.GPD_MsStamm(MSID) ON DELETE CASCADE
);


-- db_name.dbo.GPD_Spuelung definition

-- Drop table

-- DROP TABLE db_name.dbo.GPD_Spuelung;

CREATE TABLE db_name.dbo.GPD_Spuelung (
	MSID int NOT NULL,
	RECID int NOT NULL,
	SP_Anfang float NULL,
	SP_Ende float NULL,
	SP_Art int NULL,
	SP_Zusatz int NULL,
	SP_Dichte float NULL,
	SP_DichteEinh int NULL,
	SP_Verhalten nvarchar(255) COLLATE Latin1_General_CI_AS NULL,
	SP_Menge float NULL,
	CONSTRAINT GPD_Spuelung_PK PRIMARY KEY (MSID,RECID),
	CONSTRAINT FK_GPD_Spuelung_1 FOREIGN KEY (MSID) REFERENCES db_name.dbo.GPD_MsStamm(MSID) ON DELETE CASCADE
);


-- db_name.dbo.GPD_Wasserrecht definition

-- Drop table

-- DROP TABLE db_name.dbo.GPD_Wasserrecht;

CREATE TABLE db_name.dbo.GPD_Wasserrecht (
	MSID int NOT NULL,
	Typ nvarchar(50) COLLATE Latin1_General_CI_AS NULL,
	Nr float NULL,
	Name nvarchar(50) COLLATE Latin1_General_CI_AS NULL,
	WR1 nvarchar(255) COLLATE Latin1_General_CI_AS NULL,
	WR2 nvarchar(255) COLLATE Latin1_General_CI_AS NULL,
	WR3 nvarchar(255) COLLATE Latin1_General_CI_AS NULL,
	Nutzer nvarchar(50) COLLATE Latin1_General_CI_AS NULL,
	QMax_a float NULL,
	QMax float NULL,
	QMax_h float NULL,
	QMax_s float NULL,
	QMit float NULL,
	QMit_h float NULL,
	Bemerkung ntext COLLATE Latin1_General_CI_AS NULL,
	Datenquelle nvarchar(50) COLLATE Latin1_General_CI_AS NULL,
	CONSTRAINT GPD_Wasserrecht_PK PRIMARY KEY (MSID),
	CONSTRAINT FK_GPD_Wasserrecht_1 FOREIGN KEY (MSID) REFERENCES db_name.dbo.GPD_MsStamm(MSID) ON DELETE CASCADE
);


-- db_name.dbo.GWB_Analysen definition

-- Drop table

-- DROP TABLE db_name.dbo.GWB_Analysen;

CREATE TABLE db_name.dbo.GWB_Analysen (
	DatumID int NOT NULL,
	ParameterID int NOT NULL,
	Messwert float NULL,
	Einheit nvarchar(10) COLLATE Latin1_General_CI_AS NULL,
	Zusatz char(1) COLLATE Latin1_General_CI_AS DEFAULT '0' NULL,
	Locked char(1) COLLATE Latin1_General_CI_AS DEFAULT 'N' NULL,
	Method_ID int NULL,
	ValueStdUnit float NULL,
	StdUnit nvarchar(10) COLLATE Latin1_General_CI_AS NULL,
	IsCalculated nvarchar(1) COLLATE Latin1_General_CI_AS DEFAULT 'N' NULL,
	DataType int DEFAULT 0 NULL,
	CONSTRAINT GWB_Analysen_PK PRIMARY KEY (DatumID,ParameterID),
	CONSTRAINT GWB_Analy_Methods_FK FOREIGN KEY (Method_ID) REFERENCES db_name.dbo.GWB_AnalyMethods(ID)
);


-- db_name.dbo.GWB_Paramet definition

-- Drop table

-- DROP TABLE db_name.dbo.GWB_Paramet;

CREATE TABLE db_name.dbo.GWB_Paramet (
	ID int NOT NULL,
	ParameterKuerzel nvarchar(20) COLLATE Latin1_General_CI_AS NULL,
	ParameterName nvarchar(100) COLLATE Latin1_General_CI_AS NULL,
	StandardEinheit nvarchar(10) COLLATE Latin1_General_CI_AS NULL,
	StandardUnitSoil nvarchar(10) COLLATE Latin1_General_CI_AS NULL,
	StandardUnitEluat nvarchar(10) COLLATE Latin1_General_CI_AS NULL,
	KeyNr nvarchar(10) COLLATE Latin1_General_CI_AS NULL,
	KeyNr2 nvarchar(10) COLLATE Latin1_General_CI_AS NULL,
	ParamType int NULL,
	IsSumParam char(1) COLLATE Latin1_General_CI_AS DEFAULT 'N' NULL,
	IsOnsiteParam char(1) COLLATE Latin1_General_CI_AS DEFAULT 'N' NULL,
	MolMasse float NULL,
	Color int NULL,
	Kat1 char(1) COLLATE Latin1_General_CI_AS DEFAULT 'N' NULL,
	Kat2 char(1) COLLATE Latin1_General_CI_AS DEFAULT 'N' NULL,
	Kat3 char(1) COLLATE Latin1_General_CI_AS DEFAULT 'N' NULL,
	Kat4 char(1) COLLATE Latin1_General_CI_AS DEFAULT 'N' NULL,
	Kat5 char(1) COLLATE Latin1_General_CI_AS DEFAULT 'N' NULL,
	Kat6 char(1) COLLATE Latin1_General_CI_AS DEFAULT 'N' NULL,
	Kat7 char(1) COLLATE Latin1_General_CI_AS DEFAULT 'N' NULL,
	Kat8 char(1) COLLATE Latin1_General_CI_AS DEFAULT 'N' NULL,
	Kat9 char(1) COLLATE Latin1_General_CI_AS DEFAULT 'N' NULL,
	Kat10 char(1) COLLATE Latin1_General_CI_AS DEFAULT 'N' NULL,
	BemerkungParameter text COLLATE Latin1_General_CI_AS NULL,
	AllowNegative char(1) COLLATE Latin1_General_CI_AS DEFAULT 'N' NULL,
	Grenzwert1 float NULL,
	Grenzwert1Name nvarchar(50) COLLATE Latin1_General_CI_AS NULL,
	Grenzwert2 float NULL,
	Grenzwert2Name nvarchar(50) COLLATE Latin1_General_CI_AS NULL,
	Grenzwert3 float NULL,
	Grenzwert3Name nvarchar(50) COLLATE Latin1_General_CI_AS NULL,
	Grenzwert4 float NULL,
	Grenzwert4Name nvarchar(50) COLLATE Latin1_General_CI_AS NULL,
	Grenzwert5 float NULL,
	Grenzwert5Name nvarchar(50) COLLATE Latin1_General_CI_AS NULL,
	Grenzwert6 float NULL,
	Grenzwert6Name nvarchar(50) COLLATE Latin1_General_CI_AS NULL,
	Grenzwert7 float NULL,
	Grenzwert7Name nvarchar(50) COLLATE Latin1_General_CI_AS NULL,
	Grenzwert8 float NULL,
	Grenzwert8Name nvarchar(50) COLLATE Latin1_General_CI_AS NULL,
	StdGrenzwert char(1) COLLATE Latin1_General_CI_AS NULL,
	SeqNr int NULL,
	StandardUnitAir nvarchar(10) COLLATE Latin1_General_CI_AS NULL,
	LowerBound float NULL,
	UpperBound float NULL,
	Web_Cat nvarchar(2) COLLATE Latin1_General_CI_AS NULL,
	StdMethod_ID int NULL,
	DetectLimitWater float NULL,
	DetectLimitSoil float NULL,
	DetectLimitAqSol float NULL,
	DetectLimitAir float NULL,
	DecimalPlaces int NULL,
	ValenceNo int NULL,
	ParamGroup nvarchar(1) COLLATE Latin1_General_CI_AS NULL,
	Symbol int NULL,
	Gww nchar(1) COLLATE Latin1_General_CI_AS DEFAULT '-' NULL,
	GwwTransferDate smalldatetime NULL,
	HasUpperLimit nchar(1) COLLATE Latin1_General_CI_AS DEFAULT '+' NULL,
	CONSTRAINT GWB_Paramet_PK PRIMARY KEY (ID),
	CONSTRAINT GWB_Param_Methods_FK FOREIGN KEY (StdMethod_ID) REFERENCES db_name.dbo.GWB_AnalyMethods(ID)
);


-- db_name.dbo.GWB_SensorDepth definition

-- Drop table

-- DROP TABLE db_name.dbo.GWB_SensorDepth;

CREATE TABLE db_name.dbo.GWB_SensorDepth (
	ID int NOT NULL,
	Well_ID int NOT NULL,
	SensorDepth float NOT NULL,
	SensorDate smalldatetime NOT NULL,
	CommentText nvarchar(100) COLLATE Latin1_General_CI_AS NULL,
	MType int NULL,
	CONSTRAINT GWB_SensorDepth_PK PRIMARY KEY (ID),
	CONSTRAINT GWB_SensorDepth_Well_FK FOREIGN KEY (Well_ID) REFERENCES db_name.dbo.GWB_MSStamm(ID)
);


-- db_name.dbo.GWB_SurfaceWater_Parts definition

-- Drop table

-- DROP TABLE db_name.dbo.GWB_SurfaceWater_Parts;

CREATE TABLE db_name.dbo.GWB_SurfaceWater_Parts (
	ID int NOT NULL,
	Main_ID int NOT NULL,
	ItemName varchar(100) COLLATE Latin1_General_CI_AS NOT NULL,
	SeqNr int NULL,
	CONSTRAINT GWB_SurfaceWater_Parts_PK PRIMARY KEY (ID),
	CONSTRAINT GWB_SWParts_MainSW_FK FOREIGN KEY (Main_ID) REFERENCES db_name.dbo.GWB_SurfaceWaters(ID) ON DELETE CASCADE
);
 CREATE UNIQUE NONCLUSTERED INDEX GWB_SurfaceWaterParts_IDX2 ON db_name.dbo.GWB_SurfaceWater_Parts (  Main_ID ASC  , ItemName ASC  )  
	 WITH (  PAD_INDEX = OFF ,FILLFACTOR = 100  ,SORT_IN_TEMPDB = OFF , IGNORE_DUP_KEY = OFF , STATISTICS_NORECOMPUTE = OFF , ONLINE = OFF , ALLOW_ROW_LOCKS = ON , ALLOW_PAGE_LOCKS = ON  )
	 ON [PRIMARY ] ;


-- db_name.dbo.GWB_WellProperties_Values definition

-- Drop table

-- DROP TABLE db_name.dbo.GWB_WellProperties_Values;

CREATE TABLE db_name.dbo.GWB_WellProperties_Values (
	ID int NOT NULL,
	Property_ID int NOT NULL,
	ValueText nvarchar(50) COLLATE Latin1_General_CI_AS NOT NULL,
	CONSTRAINT GWB_WellProperties_Values_PK PRIMARY KEY (ID),
	CONSTRAINT GWB_WPValues_Property_FK FOREIGN KEY (Property_ID) REFERENCES db_name.dbo.GWB_WellProperties(ID) ON DELETE CASCADE
);


-- db_name.dbo.GPD_AsbBohrloch definition

-- Drop table

-- DROP TABLE db_name.dbo.GPD_AsbBohrloch;

CREATE TABLE db_name.dbo.GPD_AsbBohrloch (
	MSID int NOT NULL,
	RECID int NOT NULL,
	ABL_OK float NULL,
	ABL_UK float NULL,
	ABL_Verfahren int NULL,
	ABL_Werkzeug int NULL,
	ABL_Durchmesser int NULL,
	ABL_DurchmZoll nvarchar(12) COLLATE Latin1_General_CI_AS NULL,
	ABL_Notiz nvarchar(254) COLLATE Latin1_General_CI_AS NULL,
	CONSTRAINT GPD_AsbBohrloch_PK PRIMARY KEY (MSID,RECID),
	CONSTRAINT FK_GPD_AsbBohrloch_1 FOREIGN KEY (MSID) REFERENCES db_name.dbo.GPD_MsStamm(MSID) ON DELETE CASCADE
);


-- db_name.dbo.GPD_AsbSonderbau definition

-- Drop table

-- DROP TABLE db_name.dbo.GPD_AsbSonderbau;

CREATE TABLE db_name.dbo.GPD_AsbSonderbau (
	MSID int NOT NULL,
	RECID int NOT NULL,
	ASE_OK float NULL,
	ASE_UK float NULL,
	ASE_Typ int NULL,
	ASE_Durchmesser int NULL,
	ASE_Wandstaerke float NULL,
	ASE_Bemerkung nvarchar(80) COLLATE Latin1_General_CI_AS NULL,
	ASE_DurchmZoll nvarchar(12) COLLATE Latin1_General_CI_AS NULL,
	ASE_LineWidth int NULL,
	CONSTRAINT GPD_AsbSonderbau_PK PRIMARY KEY (MSID,RECID),
	CONSTRAINT FK_GPD_AsbSonderbau_1 FOREIGN KEY (MSID) REFERENCES db_name.dbo.GPD_MsStamm(MSID) ON DELETE CASCADE
);


-- db_name.dbo.GPD_AsbVerfuellung definition

-- Drop table

-- DROP TABLE db_name.dbo.GPD_AsbVerfuellung;

CREATE TABLE db_name.dbo.GPD_AsbVerfuellung (
	MSID int NOT NULL,
	RECID int NOT NULL,
	AVF_Material int NULL,
	AVF_OK float NULL,
	AVF_UK float NULL,
	AVF_Durchmesser int NULL,
	AVF_KorngroesseMin float NULL,
	AVF_KorngroesseMax float NULL,
	AVF_Bemerkung nvarchar(80) COLLATE Latin1_General_CI_AS NULL,
	AVF_DurchmZoll nvarchar(12) COLLATE Latin1_General_CI_AS NULL,
	AVF_Teilverfuellung nvarchar(1) COLLATE Latin1_General_CI_AS NULL,
	CONSTRAINT GPD_AsbVerfuellung_PK PRIMARY KEY (MSID,RECID),
	CONSTRAINT FK_GPD_AsbVerfuellung_1 FOREIGN KEY (MSID) REFERENCES db_name.dbo.GPD_MsStamm(MSID) ON DELETE CASCADE
);


-- db_name.dbo.GPD_AsbVerrohrung definition

-- Drop table

-- DROP TABLE db_name.dbo.GPD_AsbVerrohrung;

CREATE TABLE db_name.dbo.GPD_AsbVerrohrung (
	MSID int NOT NULL,
	RECID int NOT NULL,
	ARO_TourID int NULL,
	ARO_OK float NULL,
	ARO_UK float NULL,
	ARO_Typ int NULL,
	ARO_Material int NULL,
	ARO_Wandstaerke float NULL,
	ARO_Bemerkung nvarchar(80) COLLATE Latin1_General_CI_AS NULL,
	ARO_Durchmesser int NULL,
	ARO_DurchmZoll nvarchar(12) COLLATE Latin1_General_CI_AS NULL,
	ARO_DisplayPos int NULL,
	ARO_IgnoreFilter nvarchar(1) COLLATE Latin1_General_CI_AS NULL,
	ARO_FuerUebersicht nvarchar(1) COLLATE Latin1_General_CI_AS NULL,
	ARO_LineWidth int NULL,
	CONSTRAINT GPD_AsbVerrohrung_PK PRIMARY KEY (MSID,RECID),
	CONSTRAINT FK_GPD_AsbVerrohrung_1 FOREIGN KEY (MSID) REFERENCES db_name.dbo.GPD_MsStamm(MSID) ON DELETE CASCADE
);


-- db_name.dbo.GPD_HydroParam definition

-- Drop table

-- DROP TABLE db_name.dbo.GPD_HydroParam;

CREATE TABLE db_name.dbo.GPD_HydroParam (
	MSID int NOT NULL,
	GWL float NULL,
	T_rep float NULL,
	T_sim float NULL,
	Kf_sim float NULL,
	S_sim float NULL,
	P_sim nvarchar(255) COLLATE Latin1_General_CI_AS NULL,
	B_sim nvarchar(255) COLLATE Latin1_General_CI_AS NULL,
	Pv_lit nvarchar(50) COLLATE Latin1_General_CI_AS NULL,
	T_lit float NULL,
	Kf_lit float NULL,
	S_lit float NULL,
	P_lit nvarchar(255) COLLATE Latin1_General_CI_AS NULL,
	DQuelle nvarchar(255) COLLATE Latin1_General_CI_AS NULL,
	Wsp_fis float NULL,
	Datum_fis smalldatetime NULL,
	Kf_fis float NULL,
	T_fis float NULL,
	B_fis nvarchar(255) COLLATE Latin1_General_CI_AS NULL,
	S_fis float NULL,
	E_fis float NULL,
	T_logan float NULL,
	E_logan float NULL,
	Q_log float NULL,
	Q_log2 float NULL,
	S_log float NULL,
	Wsp_r_log float NULL,
	Wsp_a_log float NULL,
	Beharr_log nvarchar(50) COLLATE Latin1_General_CI_AS NULL,
	B_log nvarchar(255) COLLATE Latin1_General_CI_AS NULL,
	CONSTRAINT GPD_HydroParam_PK PRIMARY KEY (MSID),
	CONSTRAINT FK_GPD_HydroParam_1 FOREIGN KEY (MSID) REFERENCES db_name.dbo.GPD_MsStamm(MSID) ON DELETE CASCADE
);


-- db_name.dbo.GPD_Kluefte definition

-- Drop table

-- DROP TABLE db_name.dbo.GPD_Kluefte;

CREATE TABLE db_name.dbo.GPD_Kluefte (
	MSID int NOT NULL,
	RECID int NOT NULL,
	KL_Anfang float NULL,
	KL_Ende float NULL,
	KL_Neigung int NULL,
	KL_Art int NULL,
	KL_Bemerkung nvarchar(255) COLLATE Latin1_General_CI_AS NULL,
	CONSTRAINT GPD_Kluefte_PK PRIMARY KEY (MSID,RECID),
	CONSTRAINT FK_GPD_Kluefte_1 FOREIGN KEY (MSID) REFERENCES db_name.dbo.GPD_MsStamm(MSID) ON DELETE CASCADE
);


-- db_name.dbo.GPD_Log definition

-- Drop table

-- DROP TABLE db_name.dbo.GPD_Log;

CREATE TABLE db_name.dbo.GPD_Log (
	MSID int NOT NULL,
	RECID int NOT NULL,
	LG_Name nvarchar(40) COLLATE Latin1_General_CI_AS NULL,
	LG_Firma int NULL,
	LG_Datum smalldatetime NULL,
	LG_Anfang float NULL,
	LG_Ende float NULL,
	LG_Bezug int NULL,
	LG_Notitz nvarchar(254) COLLATE Latin1_General_CI_AS NULL,
	LG_Ergebnis nvarchar(254) COLLATE Latin1_General_CI_AS NULL,
	LG_Methode int NULL,
	LG_Unit int NULL,
	CONSTRAINT GPD_Log_PK PRIMARY KEY (MSID,RECID),
	CONSTRAINT FK_GPD_Log_1 FOREIGN KEY (MSID) REFERENCES db_name.dbo.GPD_MsStamm(MSID) ON DELETE CASCADE
);


-- db_name.dbo.GPD_LogData definition

-- Drop table

-- DROP TABLE db_name.dbo.GPD_LogData;

CREATE TABLE db_name.dbo.GPD_LogData (
	MSID int NOT NULL,
	LD_LogRecId int NOT NULL,
	LD_RECID int NOT NULL,
	LD_DatumZeit smalldatetime NULL,
	LD_Depth float NULL,
	LD_Value float NULL,
	LD_Unit int NULL,
	CONSTRAINT GPD_LogData_PK PRIMARY KEY (MSID,LD_LogRecId,LD_RECID),
	CONSTRAINT FK_GPD_LogData_1 FOREIGN KEY (MSID,LD_LogRecId) REFERENCES db_name.dbo.GPD_Log(MSID,RECID) ON DELETE CASCADE
);


-- db_name.dbo.GPD_MSSynonyme definition

-- Drop table

-- DROP TABLE db_name.dbo.GPD_MSSynonyme;

CREATE TABLE db_name.dbo.GPD_MSSynonyme (
	MSID int NOT NULL,
	MSSYN_ID int NOT NULL,
	MSSYN_SYNID int NOT NULL,
	MSSYN_Bezeichnung nvarchar(128) COLLATE Latin1_General_CI_AS NULL,
	CONSTRAINT GPD_MSSynonyme_PK PRIMARY KEY (MSID,MSSYN_SYNID),
	CONSTRAINT FK_GPD_MSSynonyme_1 FOREIGN KEY (MSID) REFERENCES db_name.dbo.GPD_MsStamm(MSID) ON DELETE CASCADE
);


-- db_name.dbo.GPD_MsPassConfig definition

-- Drop table

-- DROP TABLE db_name.dbo.GPD_MsPassConfig;

CREATE TABLE db_name.dbo.GPD_MsPassConfig (
	MSID int NOT NULL,
	Config ntext COLLATE Latin1_General_CI_AS NULL,
	CONSTRAINT GPD_MsPassConfig_PK PRIMARY KEY (MSID),
	CONSTRAINT FK_GPD_MsPassConfig_1 FOREIGN KEY (MSID) REFERENCES db_name.dbo.GPD_MsStamm(MSID) ON DELETE CASCADE
);


-- db_name.dbo.GWB_Param_ValueClasses definition

-- Drop table

-- DROP TABLE db_name.dbo.GWB_Param_ValueClasses;

CREATE TABLE db_name.dbo.GWB_Param_ValueClasses (
	ID int NOT NULL,
	Param_ID int NOT NULL,
	Medium int NOT NULL,
	ClassValue float NOT NULL,
	ClassColor int NULL,
	CONSTRAINT GWB_Param_ValueClasses_PK PRIMARY KEY (ID),
	CONSTRAINT GWB_PVC_Param_FK FOREIGN KEY (Param_ID) REFERENCES db_name.dbo.GWB_Paramet(ID) ON DELETE CASCADE
);
 CREATE UNIQUE NONCLUSTERED INDEX GWB_Param_ValueClasses_IDX1 ON db_name.dbo.GWB_Param_ValueClasses (  Param_ID ASC  , Medium ASC  , ClassValue ASC  )  
	 WITH (  PAD_INDEX = OFF ,FILLFACTOR = 100  ,SORT_IN_TEMPDB = OFF , IGNORE_DUP_KEY = OFF , STATISTICS_NORECOMPUTE = OFF , ONLINE = OFF , ALLOW_ROW_LOCKS = ON , ALLOW_PAGE_LOCKS = ON  )
	 ON [PRIMARY ] ;


-- db_name.dbo.GPD_AsbFilter definition

-- Drop table

-- DROP TABLE db_name.dbo.GPD_AsbFilter;

CREATE TABLE db_name.dbo.GPD_AsbFilter (
	MSID int NOT NULL,
	AFI_RohrRecID int NOT NULL,
	AFI_Schlitzweite float NULL,
	AFI_Pos int NULL,
	AFI_HydGeolEinheit int NULL,
	AFI_GwlTyp int NULL,
	AFI_Hydraulik int NULL,
	AFI_GWStockwerk int NULL,
	AFI_Bemerkung nvarchar(255) COLLATE Latin1_General_CI_AS NULL,
	CONSTRAINT GPD_AsbFilter_PK PRIMARY KEY (MSID,AFI_RohrRecID),
	CONSTRAINT FK_GPD_AsbFilter_1 FOREIGN KEY (MSID,AFI_RohrRecID) REFERENCES db_name.dbo.GPD_AsbVerrohrung(MSID,RECID) ON DELETE CASCADE
);


-- dbo.GWB_MESSSTELLEN_TEILPROJEKTE_VIEW source
USE db_name
GO

CREATE OR ALTER VIEW dbo.GWB_MESSSTELLEN_TEILPROJEKTE_VIEW AS 
  SELECT 
    S.ID as Messstellen_ID, S.KennNr, S.KennNr2, S.Bezeichnung, 
    P.ID as Teilprojekt_ID, P.ProjectDescr as TeilprojektName, P.ProjectComment as TeilprojektBeschreibung
  FROM GWB_MSStamm S, GWB_Projects P, GWB_Wells_Projects WP
  WHERE S.ID=WP.Well_ID AND P.ID=WP.Project_ID;


-- dbo.GWB_MESSSTELLEN_VIEW source

CREATE OR ALTER VIEW dbo.GWB_MESSSTELLEN_VIEW AS 
   SELECT * 
   FROM GWB_MSStamm;


-- dbo.GWB_TEILPROJEKTE_VIEW source

CREATE OR ALTER VIEW dbo.GWB_TEILPROJEKTE_VIEW AS 
  SELECT ProjectDescr as TeilprojektName, ProjectComment as TeilprojektBeschreibung
  FROM GWB_Projects;