<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://www.heurekaslu.se/w/index.php?action=history&amp;feed=atom&amp;title=Heureka_database_upgrade_script_1.0.2.0</id>
	<title>Heureka database upgrade script 1.0.2.0 - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://www.heurekaslu.se/w/index.php?action=history&amp;feed=atom&amp;title=Heureka_database_upgrade_script_1.0.2.0"/>
	<link rel="alternate" type="text/html" href="https://www.heurekaslu.se/w/index.php?title=Heureka_database_upgrade_script_1.0.2.0&amp;action=history"/>
	<updated>2026-11-19T00:51:23Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.43.11</generator>
	<entry>
		<id>https://www.heurekaslu.se/w/index.php?title=Heureka_database_upgrade_script_1.0.2.0&amp;diff=3611&amp;oldid=prev</id>
		<title>Peder at 11:27, 22 December 2009</title>
		<link rel="alternate" type="text/html" href="https://www.heurekaslu.se/w/index.php?title=Heureka_database_upgrade_script_1.0.2.0&amp;diff=3611&amp;oldid=prev"/>
		<updated>2009-12-22T11:27:44Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 12:27, 22 December 2009&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l1&quot;&gt;Line 1:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 1:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;[[:Category:Database scripts | Back to scripts]]&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&amp;lt;pre&amp;gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;IF (SELECT COUNT(*) FROM VERSION WHERE ApplicationVersion = &amp;#039;1.0.1.0&amp;#039;) = 0&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;IF (SELECT COUNT(*) FROM VERSION WHERE ApplicationVersion = &amp;#039;1.0.1.0&amp;#039;) = 0&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;BEGIN&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;BEGIN&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l98&quot;&gt;Line 98:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 101:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;	PRINT &amp;#039;Success! Database upgrade to version 1.0.2.0&amp;#039;;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;	PRINT &amp;#039;Success! Database upgrade to version 1.0.2.0&amp;#039;;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;END&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;END&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&amp;lt;/pre&amp;gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;[[Category:Database scripts]]&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Peder</name></author>
	</entry>
	<entry>
		<id>https://www.heurekaslu.se/w/index.php?title=Heureka_database_upgrade_script_1.0.2.0&amp;diff=3610&amp;oldid=prev</id>
		<title>Peder: New page: IF (SELECT COUNT(*) FROM VERSION WHERE ApplicationVersion = &#039;1.0.1.0&#039;) = 0 BEGIN 	PRINT &#039;Wrong Version of database. You must upgrade to version 1.0.1.0 before running this script.&#039;; END EL...</title>
		<link rel="alternate" type="text/html" href="https://www.heurekaslu.se/w/index.php?title=Heureka_database_upgrade_script_1.0.2.0&amp;diff=3610&amp;oldid=prev"/>
		<updated>2009-12-22T11:26:39Z</updated>

		<summary type="html">&lt;p&gt;New page: IF (SELECT COUNT(*) FROM VERSION WHERE ApplicationVersion = &amp;#039;1.0.1.0&amp;#039;) = 0 BEGIN 	PRINT &amp;#039;Wrong Version of database. You must upgrade to version 1.0.1.0 before running this script.&amp;#039;; END EL...&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;IF (SELECT COUNT(*) FROM VERSION WHERE ApplicationVersion = &amp;#039;1.0.1.0&amp;#039;) = 0&lt;br /&gt;
BEGIN&lt;br /&gt;
	PRINT &amp;#039;Wrong Version of database. You must upgrade to version 1.0.1.0 before running this script.&amp;#039;;&lt;br /&gt;
END&lt;br /&gt;
ELSE &lt;br /&gt;
BEGIN		&lt;br /&gt;
&lt;br /&gt;
	-- 1. Drop column ImpedimentPercentage&lt;br /&gt;
&lt;br /&gt;
	-- 1.1 Drop column ImpedimentPercentage from table InvReferenceUnitTree&lt;br /&gt;
	IF EXISTS (SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = &amp;#039;InvReferenceUnitTree&amp;#039; AND COLUMN_NAME = &amp;#039;ImpedimentPercentage&amp;#039;)&lt;br /&gt;
	BEGIN&lt;br /&gt;
		ALTER TABLE InvReferenceUnitTree DROP COLUMN ImpedimentPercentage&lt;br /&gt;
	END&lt;br /&gt;
&lt;br /&gt;
	-- 1.2 Remove rows containing ImpedimentPercentage for ReferenceUnitTree from InventoryTemplate&lt;br /&gt;
	IF EXISTS (SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = &amp;#039;InventoryTemplate&amp;#039;)&lt;br /&gt;
	BEGIN&lt;br /&gt;
		DELETE FROM InventoryTemplate WHERE TableName = &amp;#039;ReferenceUnitTree&amp;#039; AND ColumnName = &amp;#039;ImpedimentPercentage&amp;#039;&lt;br /&gt;
	END&lt;br /&gt;
&lt;br /&gt;
	-- 2. Change constraint PlotTypes for ReferenceUnit&lt;br /&gt;
&lt;br /&gt;
	IF EXISTS (SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = &amp;#039;ReferenceUnit&amp;#039;)&lt;br /&gt;
	BEGIN&lt;br /&gt;
		IF EXISTS (SELECT * FROM INFORMATION_SCHEMA.CONSTRAINT_COLUMN_USAGE WHERE CONSTRAINT_NAME = &amp;#039;ck_ReferenceUnit_PlotTypeCode&amp;#039;)&lt;br /&gt;
		BEGIN&lt;br /&gt;
			ALTER TABLE [dbo].[ReferenceUnit]  &lt;br /&gt;
			DROP CONSTRAINT [ck_ReferenceUnit_PlotTypeCode];&lt;br /&gt;
		END&lt;br /&gt;
&lt;br /&gt;
		UPDATE [dbo].[ReferenceUnit]  &lt;br /&gt;
		SET [PlotTypeCode] = 4 WHERE [PlotTypeCode] = 3;&lt;br /&gt;
&lt;br /&gt;
		ALTER TABLE [dbo].[ReferenceUnit]  &lt;br /&gt;
			WITH CHECK ADD CONSTRAINT [ck_ReferenceUnit_PlotTypeCode] &lt;br /&gt;
			CHECK (([PlotTypeCode]&amp;gt;=(0) AND [PlotTypeCode]&amp;lt;=(2)) OR [PlotTypeCode]=(4));&lt;br /&gt;
	END&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
	--  3. Change name of column VegitationTypeCode in table ReferenceUnit&lt;br /&gt;
	IF EXISTS (SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = &amp;#039;ReferenceUnit&amp;#039; AND COLUMN_NAME = &amp;#039;VegitationTypeCode&amp;#039;)&lt;br /&gt;
	BEGIN&lt;br /&gt;
&lt;br /&gt;
		ALTER TABLE [dbo].[ReferenceUnit] DROP CONSTRAINT ck_ReferenceUnit_VegitationTypeCode&lt;br /&gt;
&lt;br /&gt;
		EXEC sp_rename &amp;#039;ReferenceUnit.[VegitationTypeCode]&amp;#039;, &amp;#039;VegetationTypeCode&amp;#039;, &amp;#039;COLUMN&amp;#039;&lt;br /&gt;
		&lt;br /&gt;
	END&lt;br /&gt;
&lt;br /&gt;
	--  Change name of column VegitationTypeCode in table InvReferenceUnitSiteData&lt;br /&gt;
	IF EXISTS (SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = &amp;#039;InvReferenceUnitSiteData&amp;#039; AND COLUMN_NAME = &amp;#039;VegitationTypeCode&amp;#039;)&lt;br /&gt;
	BEGIN&lt;br /&gt;
		EXEC sp_rename &amp;#039;InvReferenceUnitSiteData.[VegitationTypeCode]&amp;#039;, &amp;#039;VegetationTypeCode&amp;#039;, &amp;#039;COLUMN&amp;#039;&lt;br /&gt;
	END&lt;br /&gt;
&lt;br /&gt;
	--  Change name of column ImpedimentPercentage to ImpedimentFraction in table ReferenceUnit&lt;br /&gt;
	IF EXISTS (SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = &amp;#039;ReferenceUnit&amp;#039; AND COLUMN_NAME = &amp;#039;ImpedimentPercentage&amp;#039;)&lt;br /&gt;
	BEGIN&lt;br /&gt;
		EXEC sp_rename &amp;#039;ReferenceUnit.[ImpedimentPercentage]&amp;#039;, &amp;#039;ImpedimentFraction&amp;#039;, &amp;#039;COLUMN&amp;#039;&lt;br /&gt;
	END&lt;br /&gt;
&lt;br /&gt;
	--  Change name of column ImpedimentPercentage to ImpedimentFraction in table IpakTreatmentUnit&lt;br /&gt;
	IF EXISTS (SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = &amp;#039;IpakTreatmentUnit&amp;#039; AND COLUMN_NAME = &amp;#039;ImpedimentPercentage&amp;#039;)&lt;br /&gt;
	BEGIN&lt;br /&gt;
		EXEC sp_rename &amp;#039;IpakTreatmentUnit.[ImpedimentPercentage]&amp;#039;, &amp;#039;ImpedimentFraction&amp;#039;, &amp;#039;COLUMN&amp;#039;&lt;br /&gt;
	END&lt;br /&gt;
&lt;br /&gt;
	-- Update rows containing metadata for column ReferenceUnitSiteData.VegetationTypeCode in table InventoryTemplate&lt;br /&gt;
	IF EXISTS (SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = &amp;#039;InventoryTemplate&amp;#039;)&lt;br /&gt;
	BEGIN&lt;br /&gt;
		UPDATE [dbo].[InventoryTemplate] SET ColumnName = &amp;#039;VegetationTypeCode&amp;#039; WHERE ColumnName = &amp;#039;VegitationTypeCode&amp;#039; AND TableName = &amp;#039;ReferenceUnitSiteData&amp;#039;&lt;br /&gt;
	END&lt;br /&gt;
&lt;br /&gt;
	-- 4. separate scriptfile&lt;br /&gt;
&lt;br /&gt;
	-- 5. Add column SmallTrees to table ReferenceUnit&lt;br /&gt;
&lt;br /&gt;
	IF EXISTS (SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = &amp;#039;ReferenceUnit&amp;#039;)&lt;br /&gt;
	AND NOT EXISTS(SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = &amp;#039;ReferenceUnit&amp;#039; AND COLUMN_NAME = &amp;#039;SmallTrees&amp;#039;)&lt;br /&gt;
	BEGIN&lt;br /&gt;
		ALTER TABLE [ReferenceUnit]&lt;br /&gt;
		ADD [SmallTrees] [INT] NOT NULL DEFAULT 0&lt;br /&gt;
	END&lt;br /&gt;
&lt;br /&gt;
	-- 6. Add column PlantPlotRadius&lt;br /&gt;
&lt;br /&gt;
	IF NOT EXISTS (SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = &amp;#039;Stratification&amp;#039; AND COLUMN_NAME = &amp;#039;PlantPlotRadius&amp;#039;)&lt;br /&gt;
	BEGIN&lt;br /&gt;
		ALTER TABLE [Stratification] ADD&lt;br /&gt;
			[PlantPlotRadius] [float] NULL&lt;br /&gt;
	END&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
	-- Update Version Table&lt;br /&gt;
&lt;br /&gt;
	UPDATE Version SET ApplicationVersion = &amp;#039;1.0.2.0&amp;#039;;&lt;br /&gt;
	PRINT &amp;#039;Success! Database upgrade to version 1.0.2.0&amp;#039;;&lt;br /&gt;
END&lt;/div&gt;</summary>
		<author><name>Peder</name></author>
	</entry>
</feed>