<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>ORAYLIS Blog &#187; MS SQL</title>
	<atom:link href="http://blog.oraylis.de/category/technologie/ms-sql/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.oraylis.de</link>
	<description>ORAYLIS - Einfach mehr Wissen</description>
	<lastBuildDate>Fri, 18 May 2012 09:46:47 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Product Guide f&#252;r SQL Server Denali (CTP3) ver&#246;ffentlicht</title>
		<link>http://blog.oraylis.de/2011/08/product-guide-fr-sql-server-denali-ctp3-verffentlicht/</link>
		<comments>http://blog.oraylis.de/2011/08/product-guide-fr-sql-server-denali-ctp3-verffentlicht/#comments</comments>
		<pubDate>Thu, 11 Aug 2011 14:31:00 +0000</pubDate>
		<dc:creator>David Claßen</dc:creator>
				<category><![CDATA[Allgemein]]></category>
		<category><![CDATA[Microsoft BI]]></category>
		<category><![CDATA[MS SQL]]></category>
		<category><![CDATA[CTP3]]></category>
		<category><![CDATA[Denali]]></category>
		<category><![CDATA[Product Guide]]></category>
		<category><![CDATA[SQL Server]]></category>

		<guid isPermaLink="false">http://blog.oraylis.de/2011/08/product-guide-fr-sql-server-denali-ctp3-verffentlicht/</guid>
		<description><![CDATA[<div class="wlWriterHeaderFooter" style="float:none; margin:0px; padding:4px 0px 4px 0px;"><iframe src="http://www.facebook.com/widgets/like.php?href=http://blog.oraylis.de/2011/08/product-guide-fr-sql-server-denali-ctp3-verffentlicht/" scrolling="no" frameborder="0" style="border:none; width:450px; height:80px"></iframe></div>
<p>Microsoft hat einen Product Guide zum aktuellen CTP3 Release des im kommenden Jahres erscheinenden SQL Server (Denali) veröffentlicht.</p>
<p>Das 456 MB große Paket kann im <a href="http://www.microsoft.com/download/en/details.aspx?id=27069" target="_blank">Microsoft Download Center</a> heruntergeladen werden.&#160; <br />In diesem Paket sind unterschiedlichste Materialien enthalten, die dem interessierten Anwender die wesentlichen Neuerungen näher bringen.</p>
<p>Die folgenden Materialien sind in dem Paket enthalten:</p>
<ul>
<li>14 Datenblätter zum CTP3 Release </li>
<li>8 PowerPoint Präsentationen </li>
<li>5 Whitepaper </li>
<li>44 Links zu Online-Videos inklusive 26 Präsentationen von der US-TechEd 2011 </li>
<li>6 durchklickbare Demos </li>
<li>26 Links zu Online-Dokumentationen </li>
<li>13 Hands-On Lab Preview Dokumente </li>
<li>13 selbstlaufende Demos </li>
</ul>
<p>&#160;</p>
<p>Nach dem das Paket heruntergeladen und entpackt wurde befinden sich im Zielverzeichnis mehrere Dateien und Unterordner. Um den Product Guide zu starten, muss die Datei STARTHERE.CMD ausgeführt werden. Es öffnet sich dann der definierte Standard-Browser mit der Startseite des Product Guides. Über die Startseite lassen sich dann alle angebotenen Ressourcen auswählen.</p>
<p><a href="http://blog.oraylis.de/wp-content/uploads/2011/08/Denali_CTP3_ProductGuide.png"><img style="display: inline; float: left" title="Denali_CTP3_ProductGuide" alt="Denali_CTP3_ProductGuide" align="left" src="http://blog.oraylis.de/wp-content/uploads/2011/08/Denali_CTP3_ProductGuide_thumb.png" width="600" height="302" /></a></p>
<p>&#160;</p>
<p>&#160;</p>
<p>&#160;</p>
<p>&#160;</p>
<p>&#160;</p>
<p>&#160;</p>
<p>&#160;</p>
<p>Download des Product Guides:    <br /><a href="http://www.microsoft.com/download/en/details.aspx?id=27069" target="_blank">http://www.microsoft.com/download/en/details.aspx?id=27069</a></p>
<p>Download SQL Server Code Name “Denali” CTP3:    <br /><a href="http://www.microsoft.com/betaexperience/pd/SQLDCTP3CTA/enus/default.aspx" target="_blank">http://www.microsoft.com/betaexperience/pd/SQLDCTP3CTA/enus/default.aspx</a></p>
<div style="display:block"><small><em>by David Claßen <ul class="addtoany_list"><li><a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save?linkurl=http%3A%2F%2Fblog.oraylis.de%2F2011%2F08%2Fproduct-guide-fr-sql-server-denali-ctp3-verffentlicht%2F&amp;linkname=Product%20Guide%20f%26uuml%3Br%20SQL%20Server%20Denali%20%28CTP3%29%20ver%26ouml%3Bffentlicht"><img src="http://blog.oraylis.de/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share/Bookmark"/></a></li></ul></em></small></div>]]></description>
			<content:encoded><![CDATA[<div class="wlWriterHeaderFooter" style="float:none; margin:0px; padding:4px 0px 4px 0px;"><iframe src="http://www.facebook.com/widgets/like.php?href=http://blog.oraylis.de/2011/08/product-guide-fr-sql-server-denali-ctp3-verffentlicht/" scrolling="no" frameborder="0" style="border:none; width:450px; height:80px"></iframe></div>
<p>Microsoft hat einen Product Guide zum aktuellen CTP3 Release des im kommenden Jahres erscheinenden SQL Server (Denali) veröffentlicht.</p>
<p>Das 456 MB große Paket kann im <a href="http://www.microsoft.com/download/en/details.aspx?id=27069" target="_blank">Microsoft Download Center</a> heruntergeladen werden.&#160; <br />In diesem Paket sind unterschiedlichste Materialien enthalten, die dem interessierten Anwender die wesentlichen Neuerungen näher bringen.</p>
<p>Die folgenden Materialien sind in dem Paket enthalten:</p>
<ul>
<li>14 Datenblätter zum CTP3 Release </li>
<li>8 PowerPoint Präsentationen </li>
<li>5 Whitepaper </li>
<li>44 Links zu Online-Videos inklusive 26 Präsentationen von der US-TechEd 2011 </li>
<li>6 durchklickbare Demos </li>
<li>26 Links zu Online-Dokumentationen </li>
<li>13 Hands-On Lab Preview Dokumente </li>
<li>13 selbstlaufende Demos </li>
</ul>
<p>&#160;</p>
<p>Nach dem das Paket heruntergeladen und entpackt wurde befinden sich im Zielverzeichnis mehrere Dateien und Unterordner. Um den Product Guide zu starten, muss die Datei STARTHERE.CMD ausgeführt werden. Es öffnet sich dann der definierte Standard-Browser mit der Startseite des Product Guides. Über die Startseite lassen sich dann alle angebotenen Ressourcen auswählen.</p>
<p><a href="http://blog.oraylis.de/wp-content/uploads/2011/08/Denali_CTP3_ProductGuide.png"><img style="display: inline; float: left" title="Denali_CTP3_ProductGuide" alt="Denali_CTP3_ProductGuide" align="left" src="http://blog.oraylis.de/wp-content/uploads/2011/08/Denali_CTP3_ProductGuide_thumb.png" width="600" height="302" /></a></p>
<p>&#160;</p>
<p>&#160;</p>
<p>&#160;</p>
<p>&#160;</p>
<p>&#160;</p>
<p>&#160;</p>
<p>&#160;</p>
<p>Download des Product Guides:    <br /><a href="http://www.microsoft.com/download/en/details.aspx?id=27069" target="_blank">http://www.microsoft.com/download/en/details.aspx?id=27069</a></p>
<p>Download SQL Server Code Name “Denali” CTP3:    <br /><a href="http://www.microsoft.com/betaexperience/pd/SQLDCTP3CTA/enus/default.aspx" target="_blank">http://www.microsoft.com/betaexperience/pd/SQLDCTP3CTA/enus/default.aspx</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.oraylis.de/2011/08/product-guide-fr-sql-server-denali-ctp3-verffentlicht/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Servicepack 1 f&#252;r MS SQL2008 R2</title>
		<link>http://blog.oraylis.de/2011/07/servicepack-1-fr-ms-sql2008-r2/</link>
		<comments>http://blog.oraylis.de/2011/07/servicepack-1-fr-ms-sql2008-r2/#comments</comments>
		<pubDate>Fri, 22 Jul 2011 06:38:44 +0000</pubDate>
		<dc:creator>Daniel Snellen</dc:creator>
				<category><![CDATA[MS SQL]]></category>
		<category><![CDATA[MS SSAS]]></category>
		<category><![CDATA[MS SSIS]]></category>
		<category><![CDATA[MS SSRS]]></category>
		<category><![CDATA[Technologie]]></category>

		<guid isPermaLink="false">http://blog.oraylis.de/2011/07/servicepack-1-fr-ms-sql2008-r2/</guid>
		<description><![CDATA[<p>Das Servicepack 1 für den SQL Server 2008 R2 steht bei Microsoft zum Download bereit.    <br /><a title="http://www.microsoft.com/download/en/details.aspx?id=26727" href="http://www.microsoft.com/download/en/details.aspx?id=26727">http://www.microsoft.com/download/en/details.aspx?id=26727</a></p>
<p>Das Servicepack hat die Versionsnummer 10.50.2500.0.    </p>
<p>Zu den Neuerungen gehören:</p>
<ul>
<li>Dynamic Management Views for increased supportability </li>
<li>ForceSeek for improved querying performance </li>
<li>Data-tier Application Component Framework (DAC Fx) for improved database upgrade </li>
<li>Disk space control for PowerPivot </li>
</ul>
<p>Weitere Info befinden sich auf der Download Seite von Microsoft.</p>
<div style="display:block"><small><em>by Daniel Snellen <ul class="addtoany_list"><li><a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save?linkurl=http%3A%2F%2Fblog.oraylis.de%2F2011%2F07%2Fservicepack-1-fr-ms-sql2008-r2%2F&amp;linkname=Servicepack%201%20f%26uuml%3Br%20MS%20SQL2008%20R2"><img src="http://blog.oraylis.de/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share/Bookmark"/></a></li></ul></em></small></div>]]></description>
			<content:encoded><![CDATA[<p>Das Servicepack 1 für den SQL Server 2008 R2 steht bei Microsoft zum Download bereit.    <br /><a title="http://www.microsoft.com/download/en/details.aspx?id=26727" href="http://www.microsoft.com/download/en/details.aspx?id=26727">http://www.microsoft.com/download/en/details.aspx?id=26727</a></p>
<p>Das Servicepack hat die Versionsnummer 10.50.2500.0.    </p>
<p>Zu den Neuerungen gehören:</p>
<ul>
<li>Dynamic Management Views for increased supportability </li>
<li>ForceSeek for improved querying performance </li>
<li>Data-tier Application Component Framework (DAC Fx) for improved database upgrade </li>
<li>Disk space control for PowerPivot </li>
</ul>
<p>Weitere Info befinden sich auf der Download Seite von Microsoft.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.oraylis.de/2011/07/servicepack-1-fr-ms-sql2008-r2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MS SQL Server 2008 SP2 ver&#246;ffentlicht</title>
		<link>http://blog.oraylis.de/2010/10/ms-sql-server-2008-sp2-verffentlicht/</link>
		<comments>http://blog.oraylis.de/2010/10/ms-sql-server-2008-sp2-verffentlicht/#comments</comments>
		<pubDate>Fri, 15 Oct 2010 09:27:58 +0000</pubDate>
		<dc:creator>Daniel Snellen</dc:creator>
				<category><![CDATA[MS SQL]]></category>
		<category><![CDATA[2008]]></category>

		<guid isPermaLink="false">http://blog.oraylis.de/2010/10/ms-sql-server-2008-sp2-verffentlicht/</guid>
		<description><![CDATA[<p>&#160;</p>
<p>Am 29.09.2010 hat Microsoft das Servicepack 2 für den SQL Server 2008 veröffentlicht.    <br />Der SQL Server hat nach dem Einspielen des SP die Version 10.00.4000.00.</p>
<p>Auf dieser Webseite kann das Servicepack heruntergeladen werden:    <br /><a title="http://www.microsoft.com/downloads/en/details.aspx?FamilyID=8fbfc1de-d25e-4790-88b5-7dda1f1d4e17&amp;displaylang=en" href="http://www.microsoft.com/downloads/en/details.aspx?FamilyID=8fbfc1de-d25e-4790-88b5-7dda1f1d4e17&amp;displaylang=en">http://www.microsoft.com/downloads/en/details.aspx?FamilyID=8fbfc1de-d25e-4790-88b5-7dda1f1d4e17&amp;displaylang=en</a></p>
<p>Dieses SP ist für folgende Versionen geeignet:</p>
<ul>
<li>Microsoft SQL Server 2008 Standard </li>
<li>Microsoft SQL Server 2008 Standard Edition for Small Business </li>
<li>Microsoft SQL Server 2008 Developer </li>
<li>Microsoft SQL Server 2008 Enterprise </li>
<li>Microsoft SQL Server 2008 Express </li>
<li>Microsoft SQL Server 2008 Express with Advanced Services </li>
<li>Microsoft SQL Server 2008 Web </li>
<li>Microsoft SQL Server 2008 Workgroup </li>
<li>Microsoft SQL Server 2008 Analysis Services </li>
<li>Microsoft SQL Server 2008 Reporting Services </li>
</ul>
<p>&#160;</p>
<p>Die Release Notes finden Sie hier:   <br /><a title="http://social.technet.microsoft.com/wiki/contents/articles/microsoft-sql-server-2008-sp2-release-notes.aspx" href="http://social.technet.microsoft.com/wiki/contents/articles/microsoft-sql-server-2008-sp2-release-notes.aspx">http://social.technet.microsoft.com/wiki/contents/articles/microsoft-sql-server-2008-sp2-release-notes.aspx</a></p>
<div style="display:block"><small><em>by Daniel Snellen <ul class="addtoany_list"><li><a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save?linkurl=http%3A%2F%2Fblog.oraylis.de%2F2010%2F10%2Fms-sql-server-2008-sp2-verffentlicht%2F&amp;linkname=MS%20SQL%20Server%202008%20SP2%20ver%26ouml%3Bffentlicht"><img src="http://blog.oraylis.de/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share/Bookmark"/></a></li></ul></em></small></div>]]></description>
			<content:encoded><![CDATA[<p>&#160;</p>
<p>Am 29.09.2010 hat Microsoft das Servicepack 2 für den SQL Server 2008 veröffentlicht.    <br />Der SQL Server hat nach dem Einspielen des SP die Version 10.00.4000.00.</p>
<p>Auf dieser Webseite kann das Servicepack heruntergeladen werden:    <br /><a title="http://www.microsoft.com/downloads/en/details.aspx?FamilyID=8fbfc1de-d25e-4790-88b5-7dda1f1d4e17&amp;displaylang=en" href="http://www.microsoft.com/downloads/en/details.aspx?FamilyID=8fbfc1de-d25e-4790-88b5-7dda1f1d4e17&amp;displaylang=en">http://www.microsoft.com/downloads/en/details.aspx?FamilyID=8fbfc1de-d25e-4790-88b5-7dda1f1d4e17&amp;displaylang=en</a></p>
<p>Dieses SP ist für folgende Versionen geeignet:</p>
<ul>
<li>Microsoft SQL Server 2008 Standard </li>
<li>Microsoft SQL Server 2008 Standard Edition for Small Business </li>
<li>Microsoft SQL Server 2008 Developer </li>
<li>Microsoft SQL Server 2008 Enterprise </li>
<li>Microsoft SQL Server 2008 Express </li>
<li>Microsoft SQL Server 2008 Express with Advanced Services </li>
<li>Microsoft SQL Server 2008 Web </li>
<li>Microsoft SQL Server 2008 Workgroup </li>
<li>Microsoft SQL Server 2008 Analysis Services </li>
<li>Microsoft SQL Server 2008 Reporting Services </li>
</ul>
<p>&#160;</p>
<p>Die Release Notes finden Sie hier:   <br /><a title="http://social.technet.microsoft.com/wiki/contents/articles/microsoft-sql-server-2008-sp2-release-notes.aspx" href="http://social.technet.microsoft.com/wiki/contents/articles/microsoft-sql-server-2008-sp2-release-notes.aspx">http://social.technet.microsoft.com/wiki/contents/articles/microsoft-sql-server-2008-sp2-release-notes.aspx</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.oraylis.de/2010/10/ms-sql-server-2008-sp2-verffentlicht/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Backup Strategie und Transaction Log</title>
		<link>http://blog.oraylis.de/2010/10/backup-strategie-und-transaction-log/</link>
		<comments>http://blog.oraylis.de/2010/10/backup-strategie-und-transaction-log/#comments</comments>
		<pubDate>Tue, 12 Oct 2010 07:07:15 +0000</pubDate>
		<dc:creator>Daniel Snellen</dc:creator>
				<category><![CDATA[MS SQL]]></category>
		<category><![CDATA[Backup]]></category>
		<category><![CDATA[Recovery Model]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[SQL 2008 R2]]></category>
		<category><![CDATA[Transaction Log]]></category>

		<guid isPermaLink="false">http://blog.oraylis.de/2010/10/backup-strategie-und-transaction-log/</guid>
		<description><![CDATA[<p>Bereits bei der Erstellung eines DWH sollte man sich auch Gedanken über die richtige Backup Strategie machen, da diese sonst auch schnell vergessen werden kann.</p>
<p>Ein falsches bzw. nicht konfiguriertes Backup kann dazu führen, dass das Transaction Log die Festplatte vollständig&#160; beschreibt und die betroffene Datenbank nicht mehr verfügbar ist.&#160; <br />Aus diesem Grund werde ich hier den Zusammenhang zwischen den Transaction Log und dem Recovery Model der Datenbank beschreiben.</p>
<h4>Funktion des Transaktion Log</h4>
<p>Das Transaktion Log dient zur Ausfallsicherheit. Abhängig vom Recovery Model verhält sich das Transaction Log unterschiedlich.    <br />Zuerst werde ich die allgemeine Funktion des Transaktion Log beschreiben, später im Abschnitt Recovery Model werde ich dann auf die Besonderheiten eingehen.</p>
<p>Das Transaction Log tritt nur bei <span>Schreibvorgängen</span> in Aktion, z.B. insert, update usw.</p>
<p>Nehmen wir eine Insert Transaktion.    <br />Diese Transaktion wird vom SQL Server angenommen. Bevor er diese in die Datenbank übernimmt, wird sie in den Arbeitsspeicher (RAM) <strong>und</strong> in das Transaction Log geschrieben.     <br />Dieser Vorgang geschieht gleichzeitig und hat das Ziel die Wartezeit für den Benutzer/Prozess zu reduzieren.</p>
<p>Sollte nun z.B. ein Stromausfall eintreten, bevor die Transaktion in die Datenbank übernommen wurde, wäre der Inhalt im RAM verloren und die Datenbank inkonsistent.</p>
<p>Das Transaction Log stellt in diesem Fall die Ausfallsicherheit für den Arbeitsspeicher da.    <br />Solange eine Transaction nicht in die Datenbank übernommen wurde, ist diese im Log auch noch als “aktiv” gekennzeichnet.     <br />Sollte z.B. nach dem Stromausfall der Server wieder starten, erkennt der SQL Server, dass es noch nicht abgeschlossene Transaktionen im Log gibt und überführt diese zuerst in die Datenbank bevor diese wieder erreichbar ist.</p>
<p>Im <span>Normalbetrieb</span> werden die im Arbeitsspeicher abgelegten Transaktionen sobald wie möglich in die Datenbank übernommen; je nach Auslastung des SQL Servers kann es jedoch auch einige Zeit dauern.     <br />Eine genaue Zeitangabe kann jedoch nicht gemacht werden.</p>
<p>Sobald eine Transaktion in die Datenbank übernommen wurde, wird diese aus dem Arbeitsspeicher gelöscht und im Transaction Log als “übernommen” markiert.</p>
<p>wird der SQL Server geplant beendet, so werden zunächst alle Transaktionen in die Datenbank übernommen und anschließend der Dienst beendet.</p>
<p>Wie nun mit den “fertigen” Transaktionen im Log weiter verfahren wird, das ist abhängig vom Recovery Model.</p>
<h4>Recovery Model</h4>
<p>Der MS SQL Server kennt drei Recovery Modele <strong>Simple, Full </strong>und <strong>Bulk-logged</strong> standardmäßig ist bei allen neuen Datenbanken<strong> Full</strong> eingestellt. Diese Einstellung für neue Datenbaken kann angepasst werden indem das Recovery Model der model-Datenbank geändert wird.     <br />Diese Datenbank dient als Vorlage für alle neuen Datenbanken.</p>
<p>Die Einstellung des Recovery Model kann jederzeit auch im laufenden Betrieb geändert werden, beachten Sie jedoch, dass diese Änderung auch Auswirkung auf Ihre Backup Strategie hat und pro Datenbank eingestellt wird.</p>
<p><a href="http://blog.oraylis.de/wp-content/uploads/2010/10/image3.png"><img style="border-right-width: 0px;margin: 0px;padding-left: 0px;padding-right: 0px;border-top-width: 0px;border-bottom-width: 0px;border-left-width: 0px;padding-top: 0px" border="0" alt="image" src="http://blog.oraylis.de/wp-content/uploads/2010/10/image_thumb3.png" width="244" height="220" /></a></p>
<h5>Simple</h5>
<p>Diese Model ist, wie der Name schon sagt, das einfachste. Sobald eine Transaktion in die Datenbank übernommen und im Log quittiert wurde, wird diese auch im Log gelöscht.    <br />Das bedeutet auch, dass das Log nur einen geringen Speicherplatz Festplatten benötigt.</p>
<p>Wenn für eine Datenbank gar kein Backup eingerichtet werden soll, muss für diese Datenbank das Recovery Model Simple ausgewählt werden, weil ansonsten das Transaction Log die Festplatte vollschreibt und der SQL Dienst gestoppt wird.</p>
<h5>Full</h5>
<p>Im Gegensatz zu “Simple” werden die Transaktionen nach erfolgreicher Übernahme in die Datenbank nicht gelöscht, sondern nur quittiert.    <br />Das Transaction Log wird nur durch ein Transaction Log Backup gelöscht.</p>
<p>D.h., in diesem Model sollte immer ein Datenbank- und Transaction Log Backup durchgeführt werden, damit die Festplatten nicht vollgeschrieben werden.</p>
<p>Dieses Model hat einen großen Vorteil: Es kann zur minutengenauen Wiederherstellung der Datenbank z.B. bei einem Festplattenausfall, Fehlfunktion sowie Falscheingabe genutzt werden.    <br />Hierfür ist jedoch notwendig, dass die Transaction Logs häufig gesichert werden. Man kann sagen, je geringer der Datenverlust sein darf, desto häufiger muss das Transaction Log gesichert werden. Um die Wiederherstellungszeit gering zu halten, sollte jedoch mindestens einmal Täglich eine Datenbanksicherung durchgeführt werden.</p>
<h5>Bulk-logged</h5>
<p>Das “Bulk-logged” Model ist fast identisch mit “Full”. Es unterscheidete sich nur insofern, dass Bulk Insert nur minimal protokoliert werden, so dass diese nicht einzeln wieder hergestellt werden können.</p>
<h4>Backup Strategie</h4>
<p>Für die richtige Backup Strategie gibt es leider keine “Out of the Box” Lösung, weil jede Datenbank andere Anforderungen hat.    <br />Auch <em>kein Backup zumachen</em> kann eine Strategie sein.</p>
<p>Wichtig ist nur, dass das Recovery Model entsprechend an die Strategie angepasst wird.</p>
<div style="display:block"><small><em>by Daniel Snellen <ul class="addtoany_list"><li><a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save?linkurl=http%3A%2F%2Fblog.oraylis.de%2F2010%2F10%2Fbackup-strategie-und-transaction-log%2F&amp;linkname=Backup%20Strategie%20und%20Transaction%20Log"><img src="http://blog.oraylis.de/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share/Bookmark"/></a></li></ul></em></small></div>]]></description>
			<content:encoded><![CDATA[<p>Bereits bei der Erstellung eines DWH sollte man sich auch Gedanken über die richtige Backup Strategie machen, da diese sonst auch schnell vergessen werden kann.</p>
<p>Ein falsches bzw. nicht konfiguriertes Backup kann dazu führen, dass das Transaction Log die Festplatte vollständig&#160; beschreibt und die betroffene Datenbank nicht mehr verfügbar ist.&#160; <br />Aus diesem Grund werde ich hier den Zusammenhang zwischen den Transaction Log und dem Recovery Model der Datenbank beschreiben.</p>
<h4>Funktion des Transaktion Log</h4>
<p>Das Transaktion Log dient zur Ausfallsicherheit. Abhängig vom Recovery Model verhält sich das Transaction Log unterschiedlich.    <br />Zuerst werde ich die allgemeine Funktion des Transaktion Log beschreiben, später im Abschnitt Recovery Model werde ich dann auf die Besonderheiten eingehen.</p>
<p>Das Transaction Log tritt nur bei <span>Schreibvorgängen</span> in Aktion, z.B. insert, update usw.</p>
<p>Nehmen wir eine Insert Transaktion.    <br />Diese Transaktion wird vom SQL Server angenommen. Bevor er diese in die Datenbank übernimmt, wird sie in den Arbeitsspeicher (RAM) <strong>und</strong> in das Transaction Log geschrieben.     <br />Dieser Vorgang geschieht gleichzeitig und hat das Ziel die Wartezeit für den Benutzer/Prozess zu reduzieren.</p>
<p>Sollte nun z.B. ein Stromausfall eintreten, bevor die Transaktion in die Datenbank übernommen wurde, wäre der Inhalt im RAM verloren und die Datenbank inkonsistent.</p>
<p>Das Transaction Log stellt in diesem Fall die Ausfallsicherheit für den Arbeitsspeicher da.    <br />Solange eine Transaction nicht in die Datenbank übernommen wurde, ist diese im Log auch noch als “aktiv” gekennzeichnet.     <br />Sollte z.B. nach dem Stromausfall der Server wieder starten, erkennt der SQL Server, dass es noch nicht abgeschlossene Transaktionen im Log gibt und überführt diese zuerst in die Datenbank bevor diese wieder erreichbar ist.</p>
<p>Im <span>Normalbetrieb</span> werden die im Arbeitsspeicher abgelegten Transaktionen sobald wie möglich in die Datenbank übernommen; je nach Auslastung des SQL Servers kann es jedoch auch einige Zeit dauern.     <br />Eine genaue Zeitangabe kann jedoch nicht gemacht werden.</p>
<p>Sobald eine Transaktion in die Datenbank übernommen wurde, wird diese aus dem Arbeitsspeicher gelöscht und im Transaction Log als “übernommen” markiert.</p>
<p>wird der SQL Server geplant beendet, so werden zunächst alle Transaktionen in die Datenbank übernommen und anschließend der Dienst beendet.</p>
<p>Wie nun mit den “fertigen” Transaktionen im Log weiter verfahren wird, das ist abhängig vom Recovery Model.</p>
<h4>Recovery Model</h4>
<p>Der MS SQL Server kennt drei Recovery Modele <strong>Simple, Full </strong>und <strong>Bulk-logged</strong> standardmäßig ist bei allen neuen Datenbanken<strong> Full</strong> eingestellt. Diese Einstellung für neue Datenbaken kann angepasst werden indem das Recovery Model der model-Datenbank geändert wird.     <br />Diese Datenbank dient als Vorlage für alle neuen Datenbanken.</p>
<p>Die Einstellung des Recovery Model kann jederzeit auch im laufenden Betrieb geändert werden, beachten Sie jedoch, dass diese Änderung auch Auswirkung auf Ihre Backup Strategie hat und pro Datenbank eingestellt wird.</p>
<p><a href="http://blog.oraylis.de/wp-content/uploads/2010/10/image3.png"><img style="border-right-width: 0px;margin: 0px;padding-left: 0px;padding-right: 0px;border-top-width: 0px;border-bottom-width: 0px;border-left-width: 0px;padding-top: 0px" border="0" alt="image" src="http://blog.oraylis.de/wp-content/uploads/2010/10/image_thumb3.png" width="244" height="220" /></a></p>
<h5>Simple</h5>
<p>Diese Model ist, wie der Name schon sagt, das einfachste. Sobald eine Transaktion in die Datenbank übernommen und im Log quittiert wurde, wird diese auch im Log gelöscht.    <br />Das bedeutet auch, dass das Log nur einen geringen Speicherplatz Festplatten benötigt.</p>
<p>Wenn für eine Datenbank gar kein Backup eingerichtet werden soll, muss für diese Datenbank das Recovery Model Simple ausgewählt werden, weil ansonsten das Transaction Log die Festplatte vollschreibt und der SQL Dienst gestoppt wird.</p>
<h5>Full</h5>
<p>Im Gegensatz zu “Simple” werden die Transaktionen nach erfolgreicher Übernahme in die Datenbank nicht gelöscht, sondern nur quittiert.    <br />Das Transaction Log wird nur durch ein Transaction Log Backup gelöscht.</p>
<p>D.h., in diesem Model sollte immer ein Datenbank- und Transaction Log Backup durchgeführt werden, damit die Festplatten nicht vollgeschrieben werden.</p>
<p>Dieses Model hat einen großen Vorteil: Es kann zur minutengenauen Wiederherstellung der Datenbank z.B. bei einem Festplattenausfall, Fehlfunktion sowie Falscheingabe genutzt werden.    <br />Hierfür ist jedoch notwendig, dass die Transaction Logs häufig gesichert werden. Man kann sagen, je geringer der Datenverlust sein darf, desto häufiger muss das Transaction Log gesichert werden. Um die Wiederherstellungszeit gering zu halten, sollte jedoch mindestens einmal Täglich eine Datenbanksicherung durchgeführt werden.</p>
<h5>Bulk-logged</h5>
<p>Das “Bulk-logged” Model ist fast identisch mit “Full”. Es unterscheidete sich nur insofern, dass Bulk Insert nur minimal protokoliert werden, so dass diese nicht einzeln wieder hergestellt werden können.</p>
<h4>Backup Strategie</h4>
<p>Für die richtige Backup Strategie gibt es leider keine “Out of the Box” Lösung, weil jede Datenbank andere Anforderungen hat.    <br />Auch <em>kein Backup zumachen</em> kann eine Strategie sein.</p>
<p>Wichtig ist nur, dass das Recovery Model entsprechend an die Strategie angepasst wird.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.oraylis.de/2010/10/backup-strategie-und-transaction-log/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Verschieben der Master Datenbank</title>
		<link>http://blog.oraylis.de/2010/06/verschieben-der-master-datenbank/</link>
		<comments>http://blog.oraylis.de/2010/06/verschieben-der-master-datenbank/#comments</comments>
		<pubDate>Mon, 28 Jun 2010 14:09:40 +0000</pubDate>
		<dc:creator>Daniel Snellen</dc:creator>
				<category><![CDATA[MS SQL]]></category>

		<guid isPermaLink="false">http://blog.oraylis.de/2010/06/verschieben-der-master-datenbank/</guid>
		<description><![CDATA[<p>Die Master Datenbank kann nicht mittels des Befehls ALTER DATABASE verschoben werden. Das liegt daran das die Master DB alle Systeminformationen des SQL Dienstes vorhält und somit beim Starten des Dienstes direkt geladen wird.</p>
<p>Aus diesem Grund muss der Speicherort der Master DB Dateien im “SQL Server Configuration Manager” angepasst werden.</p>
<p><a href="http://blog.oraylis.de/wp-content/uploads/2010/06/image12.png"><img style="border-right-width: 0px;border-top-width: 0px;border-bottom-width: 0px;border-left-width: 0px" border="0" alt="image" src="http://blog.oraylis.de/wp-content/uploads/2010/06/image_thumb12.png" width="244" height="50" /></a> </p>
<p>Als erstes muss der SQL Server Dienst beendet werden.    <br />Als nächstes müssen die Dateien der Master DB in das neue Verzeichnis kopiert werden.     <br />Nun öffnet man die Eigenschaften der gewünschten SQL Server Instanz</p>
<p><a href="http://blog.oraylis.de/wp-content/uploads/2010/06/image13.png"><img style="border-right-width: 0px;border-top-width: 0px;border-bottom-width: 0px;border-left-width: 0px" border="0" alt="image" src="http://blog.oraylis.de/wp-content/uploads/2010/06/image_thumb13.png" width="182" height="160" /></a> </p>
<p><a href="http://blog.oraylis.de/wp-content/uploads/2010/06/image14.png"><img style="border-right-width: 0px;border-top-width: 0px;border-bottom-width: 0px;border-left-width: 0px" border="0" alt="image" src="http://blog.oraylis.de/wp-content/uploads/2010/06/image_thumb14.png" width="221" height="244" /></a> </p>
<p>Der Speicherort der Master DB ist in den <strong>Startup Parameters</strong> definiert.</p>
<p><a href="http://blog.oraylis.de/wp-content/uploads/2010/06/image15.png"><img style="border-right-width: 0px;border-top-width: 0px;border-bottom-width: 0px;border-left-width: 0px" border="0" alt="image" src="http://blog.oraylis.de/wp-content/uploads/2010/06/image_thumb15.png" width="244" height="48" /></a> </p>
</p>
<pre><font color="#004080">-dC:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\DATA\
master.mdf;-eC:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\
LOG\ERRORLOG;-lC:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\
DATA\mastlog.ldf</font></pre>
<p>&#160;</p>
<p><strong>-d</strong> Gibt die Datendatei an. </p>
<p><strong>-l</strong>&#160; Gibt die Logdatei an. </p>
<p><strong>-e</strong> Gibt den Pfad fürs Error Log an.</p>
<p>Hier kann der Pfad der Master DB Dateien jetzt auf das neue Verzeichnis, in dem die Kopien der Dateien liegen, angepasst werden.</p>
<p>Abschließend muss der SQL Server Dienst wieder gestartet werden.</p>
<div style="display:block"><small><em>by Daniel Snellen <ul class="addtoany_list"><li><a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save?linkurl=http%3A%2F%2Fblog.oraylis.de%2F2010%2F06%2Fverschieben-der-master-datenbank%2F&amp;linkname=Verschieben%20der%20Master%20Datenbank"><img src="http://blog.oraylis.de/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share/Bookmark"/></a></li></ul></em></small></div>]]></description>
			<content:encoded><![CDATA[<p>Die Master Datenbank kann nicht mittels des Befehls ALTER DATABASE verschoben werden. Das liegt daran das die Master DB alle Systeminformationen des SQL Dienstes vorhält und somit beim Starten des Dienstes direkt geladen wird.</p>
<p>Aus diesem Grund muss der Speicherort der Master DB Dateien im “SQL Server Configuration Manager” angepasst werden.</p>
<p><a href="http://blog.oraylis.de/wp-content/uploads/2010/06/image12.png"><img style="border-right-width: 0px;border-top-width: 0px;border-bottom-width: 0px;border-left-width: 0px" border="0" alt="image" src="http://blog.oraylis.de/wp-content/uploads/2010/06/image_thumb12.png" width="244" height="50" /></a> </p>
<p>Als erstes muss der SQL Server Dienst beendet werden.    <br />Als nächstes müssen die Dateien der Master DB in das neue Verzeichnis kopiert werden.     <br />Nun öffnet man die Eigenschaften der gewünschten SQL Server Instanz</p>
<p><a href="http://blog.oraylis.de/wp-content/uploads/2010/06/image13.png"><img style="border-right-width: 0px;border-top-width: 0px;border-bottom-width: 0px;border-left-width: 0px" border="0" alt="image" src="http://blog.oraylis.de/wp-content/uploads/2010/06/image_thumb13.png" width="182" height="160" /></a> </p>
<p><a href="http://blog.oraylis.de/wp-content/uploads/2010/06/image14.png"><img style="border-right-width: 0px;border-top-width: 0px;border-bottom-width: 0px;border-left-width: 0px" border="0" alt="image" src="http://blog.oraylis.de/wp-content/uploads/2010/06/image_thumb14.png" width="221" height="244" /></a> </p>
<p>Der Speicherort der Master DB ist in den <strong>Startup Parameters</strong> definiert.</p>
<p><a href="http://blog.oraylis.de/wp-content/uploads/2010/06/image15.png"><img style="border-right-width: 0px;border-top-width: 0px;border-bottom-width: 0px;border-left-width: 0px" border="0" alt="image" src="http://blog.oraylis.de/wp-content/uploads/2010/06/image_thumb15.png" width="244" height="48" /></a> </p>
</p>
<pre><font color="#004080">-dC:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\DATA\
master.mdf;-eC:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\
LOG\ERRORLOG;-lC:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\
DATA\mastlog.ldf</font></pre>
<p>&#160;</p>
<p><strong>-d</strong> Gibt die Datendatei an. </p>
<p><strong>-l</strong>&#160; Gibt die Logdatei an. </p>
<p><strong>-e</strong> Gibt den Pfad fürs Error Log an.</p>
<p>Hier kann der Pfad der Master DB Dateien jetzt auf das neue Verzeichnis, in dem die Kopien der Dateien liegen, angepasst werden.</p>
<p>Abschließend muss der SQL Server Dienst wieder gestartet werden.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.oraylis.de/2010/06/verschieben-der-master-datenbank/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Datenbankdateien verschieben</title>
		<link>http://blog.oraylis.de/2010/06/datenbankdateien-verschieben/</link>
		<comments>http://blog.oraylis.de/2010/06/datenbankdateien-verschieben/#comments</comments>
		<pubDate>Mon, 21 Jun 2010 11:23:39 +0000</pubDate>
		<dc:creator>Daniel Snellen</dc:creator>
				<category><![CDATA[MS SQL]]></category>
		<category><![CDATA[Database Migration]]></category>
		<category><![CDATA[SQL]]></category>

		<guid isPermaLink="false">http://blog.oraylis.de/2010/06/datenbankdateien-verschieben/</guid>
		<description><![CDATA[<p>Unter Umständen kommt man in die Situation, dass man die Datenbankdateien sowie Log-Files verschoben werden müssen, z.B. weil eine Festplatte voll ist.</p>
<p>In diesem Beispiel heißt die Datenbank <strong>DB1</strong> und hat folgende Dateien.</p>
<table border="0" cellspacing="0" cellpadding="2" width="400">
<tbody>
<tr>
<td width="200" valign="top"><span style="font-size: xx-small">File Name</span></td>
<td width="200" valign="top"><span style="font-size: xx-small">File</span></td>
</tr>
<tr>
<td width="200" valign="top"><span style="font-size: xx-small">DB1_File</span></td>
<td width="200" valign="top"><span style="font-size: xx-small">c:\data\db1_file.mdf</span></td>
</tr>
<tr>
<td width="200" valign="top"><span style="font-size: xx-small">DB1_Log</span></td>
<td width="200" valign="top"><span style="font-size: xx-small">c:\data\db1_log.ldf</span></td>
</tr>
</tbody>
</table>
<p>Die Dateien sollen jetzt von <strong>c:\data</strong> nach <strong>x:\data</strong> verschoben werden.</p>
<p>1. <span style="color: #004080">ALTER DATABASE DB1 SET OFFLINE WITH ROLLBACK_IMMEDIATE</span></p>
<p>2. Kopiere die Datenbankdateien von <strong>C:\data</strong> nach <strong>X:\Data</strong></p>
<p>3. <span style="color: #004080">ALTER DATABASE DB1 MODIFY FILE(NAME = DB1_Data, FILENAME = “<strong>X:\data\DB1_Data.mdf</strong>”)</span></p>
<p>4. <span style="color: #004080">ALTER DATABASE DB1 MODIFY FILE(NAME = DB1_Log, FILENAME = “<strong>x::\data\DB1_Log.ldf</strong>”)</span></p>
<p>5. <span style="color: #004080">ALTER DATABASE DB1 SET ONLINE</span></p>
<p>Wichtig: Diese Methode kann nicht auf die MASTER Datenbank angewendet werden!</p>
<p><span style="color: #808080"> </span></p>
<div style="display:block"><small><em>by Daniel Snellen <ul class="addtoany_list"><li><a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save?linkurl=http%3A%2F%2Fblog.oraylis.de%2F2010%2F06%2Fdatenbankdateien-verschieben%2F&amp;linkname=Datenbankdateien%20verschieben"><img src="http://blog.oraylis.de/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share/Bookmark"/></a></li></ul></em></small></div>]]></description>
			<content:encoded><![CDATA[<p>Unter Umständen kommt man in die Situation, dass man die Datenbankdateien sowie Log-Files verschoben werden müssen, z.B. weil eine Festplatte voll ist.</p>
<p>In diesem Beispiel heißt die Datenbank <strong>DB1</strong> und hat folgende Dateien.</p>
<table border="0" cellspacing="0" cellpadding="2" width="400">
<tbody>
<tr>
<td width="200" valign="top"><span style="font-size: xx-small">File Name</span></td>
<td width="200" valign="top"><span style="font-size: xx-small">File</span></td>
</tr>
<tr>
<td width="200" valign="top"><span style="font-size: xx-small">DB1_File</span></td>
<td width="200" valign="top"><span style="font-size: xx-small">c:\data\db1_file.mdf</span></td>
</tr>
<tr>
<td width="200" valign="top"><span style="font-size: xx-small">DB1_Log</span></td>
<td width="200" valign="top"><span style="font-size: xx-small">c:\data\db1_log.ldf</span></td>
</tr>
</tbody>
</table>
<p>Die Dateien sollen jetzt von <strong>c:\data</strong> nach <strong>x:\data</strong> verschoben werden.</p>
<p>1. <span style="color: #004080">ALTER DATABASE DB1 SET OFFLINE WITH ROLLBACK_IMMEDIATE</span></p>
<p>2. Kopiere die Datenbankdateien von <strong>C:\data</strong> nach <strong>X:\Data</strong></p>
<p>3. <span style="color: #004080">ALTER DATABASE DB1 MODIFY FILE(NAME = DB1_Data, FILENAME = “<strong>X:\data\DB1_Data.mdf</strong>”)</span></p>
<p>4. <span style="color: #004080">ALTER DATABASE DB1 MODIFY FILE(NAME = DB1_Log, FILENAME = “<strong>x::\data\DB1_Log.ldf</strong>”)</span></p>
<p>5. <span style="color: #004080">ALTER DATABASE DB1 SET ONLINE</span></p>
<p>Wichtig: Diese Methode kann nicht auf die MASTER Datenbank angewendet werden!</p>
<p><span style="color: #808080"> </span></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.oraylis.de/2010/06/datenbankdateien-verschieben/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Aggregating shape data in T-SQL</title>
		<link>http://blog.oraylis.de/2010/06/aggregating-shape-data-in-t-sql/</link>
		<comments>http://blog.oraylis.de/2010/06/aggregating-shape-data-in-t-sql/#comments</comments>
		<pubDate>Sun, 06 Jun 2010 14:46:20 +0000</pubDate>
		<dc:creator>Hilmar Buchta</dc:creator>
				<category><![CDATA[MS SQL]]></category>
		<category><![CDATA[GEO]]></category>
		<category><![CDATA[Map]]></category>
		<category><![CDATA[Spatial]]></category>
		<category><![CDATA[SQL]]></category>

		<guid isPermaLink="false">http://blog.oraylis.de/2010/06/aggregating-shape-data-in-t-sql/</guid>
		<description><![CDATA[<p align="right">SQL Server 2008 | SQL Server 2008 R2</p>
<p align="left">In order to utilize map data in SQL Server the spatial data types and the spatial functions of the SQL Server are important. In <a href="http://blog.oraylis.de/2010/05/german-map-spatial-data-for-plz-postal-code-regions/">my last post</a> I “aggregated” detailed shapes up to a surrounding shape by using the built-in STUnion() function.</p>
<p align="left">For the current post I’m using the detailed data for the German PLZ regions from my last post together with <a href="http://conceptdev.blogspot.com/2007/12/sql-server-2008-geometry-stunion.html">Craig Dunn’s function</a> for aggregating shapes. The installation of these aggregate functions is pretty straight forward. After compiling the library from the source code you have to register the new aggregate in your SQL Server database. You will find all the needed information in his post.</p>
<p align="left">Using this library, the aggregation of the shape becomes pretty easy. For example. The full aggregation for postal code region 42 now looks like this:</p>
<table border="0" cellspacing="0" cellpadding="2" width="632">
<tbody>
<tr>
<td valign="top" width="324">
<p align="center"><strong>Not aggregated</strong></p>
</td>
<td valign="top" width="306">
<p align="center"><strong>Aggregated</strong></p>
</td>
</tr>
<tr>
<td valign="top" width="324">select geom          <br />from dbo.post_pl           <br />where PLZ99 like &#8217;42%&#8217;</td>
<td valign="top" width="306">select dbo.UnionAggregate(geom.MakeValid())          <br />from dbo.post_pl           <br />where PLZ99 like &#8217;42%&#8217;</td>
</tr>
<tr>
<td valign="top" width="324"><a href="http://blog.oraylis.de/wp-content/uploads/2010/06/image.png"><img style="border-right-width: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto" title="image" border="0" alt="image" src="http://blog.oraylis.de/wp-content/uploads/2010/06/image_thumb.png" width="244" height="153" /></a></td>
<td valign="top" width="306"><a href="http://blog.oraylis.de/wp-content/uploads/2010/06/image1.png"><img style="border-right-width: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto" title="image" border="0" alt="image" src="http://blog.oraylis.de/wp-content/uploads/2010/06/image_thumb1.png" width="244" height="154" /></a> </td>
</tr>
</tbody>
</table>
<p>This is much easier than the T-SQL function from my last post. I still recommend to persist the results for later use because the geo spatial operation may be more time consuming than “normal” queries.</p>
<p>However, there are two special topics to take care of:</p>
<ol>
<li>Not all polygons may be correct (Open Geospatial Consortium type) </li>
<li>The shapes may not fit together perfectly </li>
</ol>
<p>&#160;</p>
<p>The first topic could result in errors when using the aggregation function above as well as the built-in T-SQL STUnion() function. This can be easily avoided using the MakeValid() function as shown in the example above. If you omit this function and remove the where-condition to get the aggregate of the full German map you will get a .Net error because of incorrect shapes.</p>
<p>For the second topic, take a closer look to the right picture from above. You will notice some lines within the shape. This effect becomes even more visible if we use the STBoundary() function to reduce the shape to its boundaries:</p>
<table border="0" cellspacing="0" cellpadding="2" width="630">
<tbody>
<tr>
<td valign="top" width="322">
<p align="center"><strong>Without STBuffer()</strong></p>
</td>
<td valign="top" width="306">
<p align="center"><strong>With STBuffer()</strong></p>
</td>
</tr>
<tr>
<td valign="top" width="322">select          <br />dbo.UnionAggregate(geom)           <br />&#160;&#160; .STBoundary()           <br />from dbo.post_pl where PLZ99 like &#8217;42%&#8217;</td>
<td valign="top" width="306">select          <br />dbo.UnionAggregate(geom)           <br />&#160;&#160; .STBuffer(0.00001).STBoundary()           <br />from dbo.post_pl where PLZ99 like &#8217;42%&#8217;</td>
</tr>
<tr>
<td valign="top" width="322"><a href="http://blog.oraylis.de/wp-content/uploads/2010/06/image2.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://blog.oraylis.de/wp-content/uploads/2010/06/image_thumb2.png" width="244" height="154" /></a> </td>
<td valign="top" width="306"><a href="http://blog.oraylis.de/wp-content/uploads/2010/06/image3.png"><img style="border-right-width: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto" title="image" border="0" alt="image" src="http://blog.oraylis.de/wp-content/uploads/2010/06/image_thumb3.png" width="244" height="157" /></a> </td>
</tr>
</tbody>
</table>
<p>STBuffer() simply adds some buffer around the existing shape. This can be easily examined using the following T-SQL statement with its corresponding result:</p>
<p><font face="Courier New">DECLARE @s1 AS GEOMETRY = &#8216;POLYGON((0 0, 1 0, 1 1, 0 1, 0 0))&#8217;      <br />DECLARE @s2 as GEOMETRY = &#8216;POLYGON((1.1 0, 2.1 0, 2.1 1, 1.1 1, 1.1 0))&#8217;       <br />select @s1.STUnion(@s2).STBoundary()</font></p>
<p><a href="http://blog.oraylis.de/wp-content/uploads/2010/06/image4.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://blog.oraylis.de/wp-content/uploads/2010/06/image_thumb4.png" width="240" height="116" /></a> </p>
<p>As you can see, there is a small gap between the two squares. If you don’t want to look at the coordinates, you can query the distance by using the STDistance function, for example: <font face="Courier New">select @s1.STDistance(@s2)</font>. The distance is actually 0.1 units.</p>
<p>If we now add the STBuffer function the result looks like this:</p>
<p><font face="Courier New">DECLARE @s1 AS GEOMETRY = &#8216;POLYGON((0 0, 1 0, 1 1, 0 1, 0 0))&#8217;      <br />DECLARE @s2 as GEOMETRY = &#8216;POLYGON((1.1 0, 2.1 0, 2.1 1, 1.1 1, 1.1 0))&#8217;       <br />select @s1.STUnion(@s2)<strong>.STBuffer(0.1)</strong>.STBoundary()</font></p>
<p><a href="http://blog.oraylis.de/wp-content/uploads/2010/06/image5.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://blog.oraylis.de/wp-content/uploads/2010/06/image_thumb5.png" width="240" height="127" /></a> </p>
<p>By actually extending the shape a little bit, the tiny gap in the middle of the shape disappears. This is why the map on the right side looks smoother than then one on the left side. You still need to be careful with the parameter for STBuffer. Higher parameters will result in a totally different shape. For example, if we use 4 as the parameter value in the example above, the shape looks like this:</p>
<p><a href="http://blog.oraylis.de/wp-content/uploads/2010/06/image6.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://blog.oraylis.de/wp-content/uploads/2010/06/image_thumb6.png" width="240" height="211" /></a> </p>
<p>Also higher values of STBuffer result in more time needed to compute the new shape. So in practice, you would try small values first or you could use the STDistance-function to compute the distance between the shapes.</p>
<p>As some people are surprised, the samples above are also fully functional with SQL Server 2008 because the spatial data type and functions have been introduced with SQL Server 2008. New in SQL Server 2008 R2 is the map support for Reporting Services, not the support for spatial data.</p>
<div style="display:block"><small><em>by Hilmar Buchta <ul class="addtoany_list"><li><a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save?linkurl=http%3A%2F%2Fblog.oraylis.de%2F2010%2F06%2Faggregating-shape-data-in-t-sql%2F&amp;linkname=Aggregating%20shape%20data%20in%20T-SQL"><img src="http://blog.oraylis.de/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share/Bookmark"/></a></li></ul></em></small></div>]]></description>
			<content:encoded><![CDATA[<p align="right">SQL Server 2008 | SQL Server 2008 R2</p>
<p align="left">In order to utilize map data in SQL Server the spatial data types and the spatial functions of the SQL Server are important. In <a href="http://blog.oraylis.de/2010/05/german-map-spatial-data-for-plz-postal-code-regions/">my last post</a> I “aggregated” detailed shapes up to a surrounding shape by using the built-in STUnion() function.</p>
<p align="left">For the current post I’m using the detailed data for the German PLZ regions from my last post together with <a href="http://conceptdev.blogspot.com/2007/12/sql-server-2008-geometry-stunion.html">Craig Dunn’s function</a> for aggregating shapes. The installation of these aggregate functions is pretty straight forward. After compiling the library from the source code you have to register the new aggregate in your SQL Server database. You will find all the needed information in his post.</p>
<p align="left">Using this library, the aggregation of the shape becomes pretty easy. For example. The full aggregation for postal code region 42 now looks like this:</p>
<table border="0" cellspacing="0" cellpadding="2" width="632">
<tbody>
<tr>
<td valign="top" width="324">
<p align="center"><strong>Not aggregated</strong></p>
</td>
<td valign="top" width="306">
<p align="center"><strong>Aggregated</strong></p>
</td>
</tr>
<tr>
<td valign="top" width="324">select geom          <br />from dbo.post_pl           <br />where PLZ99 like &#8217;42%&#8217;</td>
<td valign="top" width="306">select dbo.UnionAggregate(geom.MakeValid())          <br />from dbo.post_pl           <br />where PLZ99 like &#8217;42%&#8217;</td>
</tr>
<tr>
<td valign="top" width="324"><a href="http://blog.oraylis.de/wp-content/uploads/2010/06/image.png"><img style="border-right-width: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto" title="image" border="0" alt="image" src="http://blog.oraylis.de/wp-content/uploads/2010/06/image_thumb.png" width="244" height="153" /></a></td>
<td valign="top" width="306"><a href="http://blog.oraylis.de/wp-content/uploads/2010/06/image1.png"><img style="border-right-width: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto" title="image" border="0" alt="image" src="http://blog.oraylis.de/wp-content/uploads/2010/06/image_thumb1.png" width="244" height="154" /></a> </td>
</tr>
</tbody>
</table>
<p>This is much easier than the T-SQL function from my last post. I still recommend to persist the results for later use because the geo spatial operation may be more time consuming than “normal” queries.</p>
<p>However, there are two special topics to take care of:</p>
<ol>
<li>Not all polygons may be correct (Open Geospatial Consortium type) </li>
<li>The shapes may not fit together perfectly </li>
</ol>
<p>&#160;</p>
<p>The first topic could result in errors when using the aggregation function above as well as the built-in T-SQL STUnion() function. This can be easily avoided using the MakeValid() function as shown in the example above. If you omit this function and remove the where-condition to get the aggregate of the full German map you will get a .Net error because of incorrect shapes.</p>
<p>For the second topic, take a closer look to the right picture from above. You will notice some lines within the shape. This effect becomes even more visible if we use the STBoundary() function to reduce the shape to its boundaries:</p>
<table border="0" cellspacing="0" cellpadding="2" width="630">
<tbody>
<tr>
<td valign="top" width="322">
<p align="center"><strong>Without STBuffer()</strong></p>
</td>
<td valign="top" width="306">
<p align="center"><strong>With STBuffer()</strong></p>
</td>
</tr>
<tr>
<td valign="top" width="322">select          <br />dbo.UnionAggregate(geom)           <br />&#160;&#160; .STBoundary()           <br />from dbo.post_pl where PLZ99 like &#8217;42%&#8217;</td>
<td valign="top" width="306">select          <br />dbo.UnionAggregate(geom)           <br />&#160;&#160; .STBuffer(0.00001).STBoundary()           <br />from dbo.post_pl where PLZ99 like &#8217;42%&#8217;</td>
</tr>
<tr>
<td valign="top" width="322"><a href="http://blog.oraylis.de/wp-content/uploads/2010/06/image2.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://blog.oraylis.de/wp-content/uploads/2010/06/image_thumb2.png" width="244" height="154" /></a> </td>
<td valign="top" width="306"><a href="http://blog.oraylis.de/wp-content/uploads/2010/06/image3.png"><img style="border-right-width: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto" title="image" border="0" alt="image" src="http://blog.oraylis.de/wp-content/uploads/2010/06/image_thumb3.png" width="244" height="157" /></a> </td>
</tr>
</tbody>
</table>
<p>STBuffer() simply adds some buffer around the existing shape. This can be easily examined using the following T-SQL statement with its corresponding result:</p>
<p><font face="Courier New">DECLARE @s1 AS GEOMETRY = &#8216;POLYGON((0 0, 1 0, 1 1, 0 1, 0 0))&#8217;      <br />DECLARE @s2 as GEOMETRY = &#8216;POLYGON((1.1 0, 2.1 0, 2.1 1, 1.1 1, 1.1 0))&#8217;       <br />select @s1.STUnion(@s2).STBoundary()</font></p>
<p><a href="http://blog.oraylis.de/wp-content/uploads/2010/06/image4.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://blog.oraylis.de/wp-content/uploads/2010/06/image_thumb4.png" width="240" height="116" /></a> </p>
<p>As you can see, there is a small gap between the two squares. If you don’t want to look at the coordinates, you can query the distance by using the STDistance function, for example: <font face="Courier New">select @s1.STDistance(@s2)</font>. The distance is actually 0.1 units.</p>
<p>If we now add the STBuffer function the result looks like this:</p>
<p><font face="Courier New">DECLARE @s1 AS GEOMETRY = &#8216;POLYGON((0 0, 1 0, 1 1, 0 1, 0 0))&#8217;      <br />DECLARE @s2 as GEOMETRY = &#8216;POLYGON((1.1 0, 2.1 0, 2.1 1, 1.1 1, 1.1 0))&#8217;       <br />select @s1.STUnion(@s2)<strong>.STBuffer(0.1)</strong>.STBoundary()</font></p>
<p><a href="http://blog.oraylis.de/wp-content/uploads/2010/06/image5.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://blog.oraylis.de/wp-content/uploads/2010/06/image_thumb5.png" width="240" height="127" /></a> </p>
<p>By actually extending the shape a little bit, the tiny gap in the middle of the shape disappears. This is why the map on the right side looks smoother than then one on the left side. You still need to be careful with the parameter for STBuffer. Higher parameters will result in a totally different shape. For example, if we use 4 as the parameter value in the example above, the shape looks like this:</p>
<p><a href="http://blog.oraylis.de/wp-content/uploads/2010/06/image6.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://blog.oraylis.de/wp-content/uploads/2010/06/image_thumb6.png" width="240" height="211" /></a> </p>
<p>Also higher values of STBuffer result in more time needed to compute the new shape. So in practice, you would try small values first or you could use the STDistance-function to compute the distance between the shapes.</p>
<p>As some people are surprised, the samples above are also fully functional with SQL Server 2008 because the spatial data type and functions have been introduced with SQL Server 2008. New in SQL Server 2008 R2 is the map support for Reporting Services, not the support for spatial data.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.oraylis.de/2010/06/aggregating-shape-data-in-t-sql/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

