 --
 --NOTES:  
 --1.  Before running this part of the script, need to verify that the 
---'UnitsType' values used in the ODM 1.1.1 database contain valid values from 
---the ODM2 UnitsTypeCV.
+--    'UnitsType' values used in the ODM 1.1.1 database contain valid values
+--    from the ODM2 UnitsTypeCV.
 --2.  The script only moves Units from the ODM 1.1.1 database that are actually 
---used, so only need to check those and not the whole list of Units in the 
---ODM 1.1.1 database.
+--    used, so only need to check those and not the whole list of Units in the 
+--    ODM 1.1.1 database.
 -------------------------------------------------------------------------------
 
 --TODO: Verify that UnitsTypeCV terms get loaded to the ODM2 database correctly

SELECT OffsetDescription
FROM LittleBearRiverODM.dbo.OffsetTypes;

--Populate the ODM2.SamplingFeatures table with records for the Sites
--First, make sure the data type of the FeatureGeometry field is correct 
--For now using geometry type in SQL Server

-------------------------------------------------------------------------------
--Added the following 3 lines because DBWrench didn't have geometry data type, 
--but it seems to support it now so I've commented them out
--
--ALTER TABLE ODM2.ODM2.SamplingFeatures DROP COLUMN FeatureGeometry;
--ALTER TABLE ODM2.ODM2.SamplingFeatures ADD FeatureGeometry geometry NULL;
--GO
-------------------------------------------------------------------------------

--Now add the Site SamplingFeatures to the ODM2 SamplingFeatures table 
--Set the default value of the SamplingFeatureUUID attribute to NEWSQUENTIALID() 
--so the GUID is automatically generated I did this by adding a default value 
--constraint to the SamplingFeatureUUID field set to generate a 
--NEWSEQUENTIALID()when new records are entered into the SamplingFeatures table
ALTER TABLE ODM2.ODM2.SamplingFeatures ADD CONSTRAINT DF_SamplingFeatureUUID 
	DEFAULT NEWSEQUENTIALID() FOR SamplingFeatureUUID;
SET IDENTITY_INSERT ODM2.ODM2.SamplingFeatures ON; 

-------------------------------------------------------------------------------
--Populate the ODM2.Methods table
--NOTES:  
--1.  Uses the MethodIDs from the ODM 1.1.1 database as the MethodIDs in the 
--    ODM2 database.
--2.  Set ODM2.Methods.MethodTypeCV = NULL because it doesn't exist in
--    ODM 1.1.1
--3.  Set ODM2.Methods.MethodCode = ODM11.1.1.Methods.MethodID because there 
--    is no MethodCode in ODM 1.1.1.
--4.  Set ODM2.Methods.OrganizationID = NULL because Methods weren't associated
--    with Organizations in ODM 1.1.1
-------------------------------------------------------------------------------
SET IDENTITY_INSERT ODM2.ODM2.Methods ON; 
INSERT INTO ODM2.ODM2.Methods (MethodID, MethodTypeCV, MethodCode, MethodName, 
	MethodDescription, MethodLink, OrganizationID)
