<?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-05-05T22:30:02Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.35.13</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 class=&quot;diff diff-contentalign-left diff-editfont-monospace&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 11: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;&gt; &lt;/td&gt;&lt;td class='diff-marker'&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;&gt; &lt;/td&gt;&lt;td class='diff-marker'&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;&gt; &lt;/td&gt;&lt;td class='diff-marker'&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='diff-marker'&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 = '1.0.1.0') = 0&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&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 = '1.0.1.0') = 0&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&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='diff-marker'&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='diff-marker'&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 'Success! Database upgrade to version 1.0.2.0';&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&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 'Success! Database upgrade to version 1.0.2.0';&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&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='diff-marker'&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;&gt; &lt;/td&gt;&lt;td class='diff-marker'&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;&gt; &lt;/td&gt;&lt;td class='diff-marker'&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;&gt; &lt;/td&gt;&lt;td class='diff-marker'&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;&gt; &lt;/td&gt;&lt;td class='diff-marker'&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 = '1.0.1.0') = 0 BEGIN 	PRINT 'Wrong Version of database. You must upgrade to version 1.0.1.0 before running this script.'; 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 = '1.0.1.0') = 0&lt;br /&gt;
BEGIN&lt;br /&gt;
	PRINT 'Wrong Version of database. You must upgrade to version 1.0.1.0 before running this script.';&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 = 'InvReferenceUnitTree' AND COLUMN_NAME = 'ImpedimentPercentage')&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 = 'InventoryTemplate')&lt;br /&gt;
	BEGIN&lt;br /&gt;
		DELETE FROM InventoryTemplate WHERE TableName = 'ReferenceUnitTree' AND ColumnName = 'ImpedimentPercentage'&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 = 'ReferenceUnit')&lt;br /&gt;
	BEGIN&lt;br /&gt;
		IF EXISTS (SELECT * FROM INFORMATION_SCHEMA.CONSTRAINT_COLUMN_USAGE WHERE CONSTRAINT_NAME = 'ck_ReferenceUnit_PlotTypeCode')&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 = 'ReferenceUnit' AND COLUMN_NAME = 'VegitationTypeCode')&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 'ReferenceUnit.[VegitationTypeCode]', 'VegetationTypeCode', 'COLUMN'&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 = 'InvReferenceUnitSiteData' AND COLUMN_NAME = 'VegitationTypeCode')&lt;br /&gt;
	BEGIN&lt;br /&gt;
		EXEC sp_rename 'InvReferenceUnitSiteData.[VegitationTypeCode]', 'VegetationTypeCode', 'COLUMN'&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 = 'ReferenceUnit' AND COLUMN_NAME = 'ImpedimentPercentage')&lt;br /&gt;
	BEGIN&lt;br /&gt;
		EXEC sp_rename 'ReferenceUnit.[ImpedimentPercentage]', 'ImpedimentFraction', 'COLUMN'&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 = 'IpakTreatmentUnit' AND COLUMN_NAME = 'ImpedimentPercentage')&lt;br /&gt;
	BEGIN&lt;br /&gt;
		EXEC sp_rename 'IpakTreatmentUnit.[ImpedimentPercentage]', 'ImpedimentFraction', 'COLUMN'&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 = 'InventoryTemplate')&lt;br /&gt;
	BEGIN&lt;br /&gt;
		UPDATE [dbo].[InventoryTemplate] SET ColumnName = 'VegetationTypeCode' WHERE ColumnName = 'VegitationTypeCode' AND TableName = 'ReferenceUnitSiteData'&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 = 'ReferenceUnit')&lt;br /&gt;
	AND NOT EXISTS(SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'ReferenceUnit' AND COLUMN_NAME = 'SmallTrees')&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 = 'Stratification' AND COLUMN_NAME = 'PlantPlotRadius')&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 = '1.0.2.0';&lt;br /&gt;
	PRINT 'Success! Database upgrade to version 1.0.2.0';&lt;br /&gt;
END&lt;/div&gt;</summary>
		<author><name>Peder</name></author>
	</entry>
</feed>