<?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>Mattk&#039;s Website &#187; SQL Server</title>
	<atom:link href="http://www.mattk.info/tag/sql-server/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.mattk.info</link>
	<description>Blog d&#039;un développeur .NET</description>
	<lastBuildDate>Sun, 04 Jul 2010 11:04:57 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Import d’un fichier csv dans une table SQL Server</title>
		<link>http://www.mattk.info/2009/10/import-dun-fichier-csv-dans-une-table-sql-server/</link>
		<comments>http://www.mattk.info/2009/10/import-dun-fichier-csv-dans-une-table-sql-server/#comments</comments>
		<pubDate>Sun, 18 Oct 2009 21:05:50 +0000</pubDate>
		<dc:creator>Mattk</dc:creator>
				<category><![CDATA[Astuces]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[SQL Server]]></category>

		<guid isPermaLink="false">http://www.mattk.info/2009/10/import-dun-fichier-csv-dans-une-table-sql-server/</guid>
		<description><![CDATA[Un petit pense-bête bien connu : comment importer le contenu d&#8217;un fichier *.csv dans une table SQL Server ? BULK INSERT &#91;dbo&#93;.&#91;Customer&#93; FROM 'D:\customers.csv' WITH &#40; FIELDTERMINATOR = ';', ROWTERMINATOR = '\n' &#41; GO Bref&#8230; article écrit pour me permettre de retrouver facilement ce bout de code pour des usages futurs]]></description>
			<content:encoded><![CDATA[<p>Un petit pense-bête bien connu : comment importer le contenu d&#8217;un fichier *.csv dans une table SQL Server ?</p>
<div class="codecolorer-container sql default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="sql codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">BULK<br />
<span style="color: #993333; font-weight: bold;">INSERT</span> <span style="color: #66cc66;">&#91;</span>dbo<span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">.</span><span style="color: #66cc66;">&#91;</span>Customer<span style="color: #66cc66;">&#93;</span><br />
<span style="color: #993333; font-weight: bold;">FROM</span> <span style="color: #ff0000;">'D:<span style="color: #000099; font-weight: bold;">\c</span>ustomers.csv'</span><br />
<span style="color: #993333; font-weight: bold;">WITH</span><br />
<span style="color: #66cc66;">&#40;</span><br />
FIELDTERMINATOR <span style="color: #66cc66;">=</span> <span style="color: #ff0000;">';'</span><span style="color: #66cc66;">,</span><br />
ROWTERMINATOR <span style="color: #66cc66;">=</span> <span style="color: #ff0000;">'<span style="color: #000099; font-weight: bold;">\n</span>'</span><br />
<span style="color: #66cc66;">&#41;</span><br />
GO</div></div>
<p>Bref&#8230; article écrit pour me permettre de retrouver facilement ce bout de code pour des usages futurs <img src='http://www.mattk.info/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.mattk.info/2009/10/import-dun-fichier-csv-dans-une-table-sql-server/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Installation de TFS, suite et fin</title>
		<link>http://www.mattk.info/2009/06/installation-de-tfs-suite-et-fin/</link>
		<comments>http://www.mattk.info/2009/06/installation-de-tfs-suite-et-fin/#comments</comments>
		<pubDate>Mon, 01 Jun 2009 14:38:51 +0000</pubDate>
		<dc:creator>Mattk</dc:creator>
				<category><![CDATA[TFS]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[Team Foundation Server]]></category>

		<guid isPermaLink="false">http://www.mattk.info/?p=24</guid>
		<description><![CDATA[Les péripéties de mon installation de Team Foundation Server 2008 continuent&#8230; L&#8217;installation s&#8217;est bien déroulée, mais&#8230;. la procédure de création des bases de données pour le SQL Server &#38; SQL Analysis a foiré : je n&#8217;avais pas de tables dans mon Analysis Server, ce qui entraîne donc de grosses erreurs pour obtenir la liste des]]></description>
			<content:encoded><![CDATA[<p>Les péripéties de mon installation de Team Foundation Server 2008 continuent&#8230;</p>
<p>L&#8217;installation s&#8217;est bien déroulée, mais&#8230;. la procédure de création des bases de données pour le SQL Server &amp; SQL Analysis a foiré : je n&#8217;avais pas de tables dans mon Analysis Server, ce qui entraîne donc de grosses erreurs pour obtenir la liste des tâches restantes. Voici donc comment j&#8217;ai résolu le problème :</p>
<ol>
<li>Recréer tout le cube de TFS (remplacer Domain\blablabla par les bons utilisateurs, et localhost par le nom de votre serveur) :<br />
<em>setupwarehouse -o -s <span style="color: #ff0000;"><span class="searchword">Server</span></span> -d <span class="searchword">TfsWarehouse</span> -c Warehouseschema.xml -a <span style="color: #ff0000;">Domain\TfsService</span> -ra <span style="color: #ff0000;">Domain\TfsReports</span> -v -mturl <a href="http://server:8080/">http://<span class="searchword">Server</span>:8080</a> -rebuild</em></li>
<li>Suivre les étapes Thomas Jaskula dispo <a href="http://blogs.codes-sources.com/tja/archive/2009/03/13/mtfs-2008-configuration-3-probl-mes-qui-m-ont-fait-perdre-du-temps.aspx" target="_blank">ici</a></li>
</ol>
<p>Et hop, plus d&#8217;erreur et cette fois-ci mon TFS fonctionne.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.mattk.info/2009/06/installation-de-tfs-suite-et-fin/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Installer VSTFS 2008 SP1 sur SQL Server SP1</title>
		<link>http://www.mattk.info/2009/06/installer-vstfs-2008-sp1-sur-sql-server-sp1/</link>
		<comments>http://www.mattk.info/2009/06/installer-vstfs-2008-sp1-sur-sql-server-sp1/#comments</comments>
		<pubDate>Mon, 01 Jun 2009 09:27:00 +0000</pubDate>
		<dc:creator>Mattk</dc:creator>
				<category><![CDATA[TFS]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[Team Foundation Server]]></category>
		<category><![CDATA[Visual Studio]]></category>

		<guid isPermaLink="false">http://www.mattk.info/?p=22</guid>
		<description><![CDATA[Pour tout ce qui concerne la sauvegarde de données, je suis un grand un flemmard. Ajoutons à cela le fait que j&#8217;apprécie tout de même le fait de pouvoir faire du contrôle de version sur mes projets, et un minimum de gestion de projet&#8230;.. cela donne une envie d&#8217;installer Visual Studio Team Foundation Server 2008.]]></description>
			<content:encoded><![CDATA[<p>Pour tout ce qui concerne la sauvegarde de données, je suis un grand un flemmard. Ajoutons à cela le fait que j&#8217;apprécie tout de même le fait de pouvoir faire du contrôle de version sur mes projets, et un minimum de gestion de projet&#8230;.. cela donne une envie d&#8217;installer Visual Studio Team Foundation Server 2008.</p>
<p>Je récupére donc mon vieux pc portable (Pentium M 1,6Ghz ; 2Go de ram) et installe les pré-requis :</p>
<ol>
<li>Windows Server 2008 SP2</li>
<li>IIS7 + options de compatibilités IIS6<br />
<em>Petite remarque au passage : FTP7 a été mis à jour en FTP7.5 et le module URL Rewrite est passé en version 1.1, plus d&#8217;infos sur http://www.iis.net</em></li>
<li>SQL Server 2008 SP1</li>
</ol>
<p>On arrive au moment critique : l&#8217;installation de VSTS. Première farce, la version 2008 RTM n&#8217;est pas compatible SQL Serv 2008. Il est donc nécessaire de télécharger le SP1 de VSTS 2008 et de le fusionner à l&#8217;install de VSTS avec la procédure suivante fournie par MS:</p>
<ol>
<li><a href="http://go.microsoft.com/fwlink/?LinkId=113998">Téléchargez le SP1 sur le site Web Microsoft</a> et enregistrez la mise à jour dans un dossier sur l&#8217;ordinateur local (nommé <em>&lt;sp1 dir&gt;</em>)</li>
<li>À partir des fichiers d&#8217;origine du DVD de Team Foundation Server, copiez le dossier AT à un emplacement sur l&#8217;ordinateur local  (je nommerai cet emplacement <em>&lt;local AT&gt;</em>).</li>
<li>Ouvrez une fenêtre d&#8217;invite de commandes et tapez la commande suivante (&lt;sp1 extract&gt; est le dossier d&#8217;extraction du service pack) :<br />
<em>&lt;sp1 dir&gt;/TFS90SP1-KB949786-ENU /extract:&lt;sp1 extract&gt;</em></li>
<li>Créez le dossier <em>&lt;tfs merged&gt;</em> qui contiendra l&#8217;installation fusionnée, puis exécuter la commande suivante :<br />
<em>msiexec /a <strong>&lt;local AT&gt;</strong>vs_setup.msi /p <strong>&lt;sp1 extract&gt;</strong>TFS90sp1-KB949786.msp TARGETDIR=<strong>&lt;tfs merged&gt;</strong></em></li>
</ol>
<p>Petite note : &lt;tfs merged&gt; doit être un chemin absolu, les autres peuvent être des chemins relatifs.</p>
<p>Et donc là tout content, vous exécutez l&#8217;installation&#8230;&#8230; Et vous obtenez une magnifique erreur qui vous indique que votre instance d&#8217;SQL Server 2008 n&#8217;est pas compatible avec TFS. Youpi \o/<br />
En fouillant un peu sur le web, j&#8217;ai réussi à trouver une solution :</p>
<ol>
<li>Dans le dossier &lt;tfs merged&gt;, ouvrez le fichier : <span style="color: #ff0000;">Hcpackage.xml</span></li>
<li><span style="color: #ff0000;"><span style="color: #000000;">Cherchez :<br />
</span></span>&lt;WQL namespace=&nbsp;&raquo;\.rootMicrosoftSqlServerComputerManagement10&#8243; query=&nbsp;&raquo;SELECT * FROM sqlserviceadvancedproperty WHERE ServiceName=&#8217;[%VSTF_SERVICENAME_MSSQL%]&#8216; AND PropertyName=&#8217;VERSION&#8217; AND PropertyStrValue&amp;gt;=&#8217;10.00.1433&#8242; AND PropertyStrValue <span style="color: #ff0000;">LIKE &#8217;10.00.%&#8217;&nbsp;&raquo;</span> action=&nbsp;&raquo;=&nbsp;&raquo; count=&nbsp;&raquo;0&#8243; /&gt;</p>
<p>Remplacez par :<br />
&lt;WQL namespace=&nbsp;&raquo;\.rootMicrosoftSqlServerComputerManagement10&#8243; query=&nbsp;&raquo;SELECT * FROM sqlserviceadvancedproperty WHERE ServiceName=&#8217;[%VSTF_SERVICENAME_MSSQL%]&#8216; AND PropertyName=&#8217;VERSION&#8217; AND PropertyStrValue&amp;gt;=&#8217;10.00.1433&#8242; AND PropertyStrValue <span style="color: #ff0000;">LIKE &#8217;10.%&#8217;&nbsp;&raquo;</span> action=&nbsp;&raquo;=&nbsp;&raquo; count=&nbsp;&raquo;0&#8243; /&gt;</li>
<li><span style="color: #ff0000;"><span style="color: #000000;">Cette entrée est présente deux fois dans le fichier, donc relancez la recherche afin de bien modifier les 2 occurences.</span></span></li>
<li><span style="color: #ff0000;"><span style="color: #000000;">Cherchez :<br />
</span></span>&lt;MsiProductVersionCheck prodid=&nbsp;&raquo;[%SQLServer2008%]&nbsp;&raquo; action=&nbsp;&raquo;&amp;lt;&nbsp;&raquo; <span style="color: #ff0000;">version=&nbsp;&raquo;10.1&#8243;</span> /&gt;<span style="color: #ff0000;"><span style="color: #000000;"><br />
Remplacez par :<br />
</span></span>&lt;MsiProductVersionCheck prodid=&nbsp;&raquo;[%SQLServer2008%]&nbsp;&raquo; action=&nbsp;&raquo;&amp;lt;&nbsp;&raquo; <span style="color: #ff0000;">version=&nbsp;&raquo;10.2&#8243;</span> /&gt;</li>
<li><span style="color: #ff0000;"><span style="color: #000000;">Sauvegardez </span></span>Hcpackage.xml</li>
<li>Lancez le setup présent dans &lt;tfs merged&gt; et &#8230;&#8230;.. oh miracle, tout s&#8217;installe <img src='http://www.mattk.info/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </li>
</ol>
<p>Voilà, il m&#8217;a donc fallu une bonne journée pour trouver cette solution.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.mattk.info/2009/06/installer-vstfs-2008-sp1-sur-sql-server-sp1/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Obtenir les coordonnées géographique d’une région</title>
		<link>http://www.mattk.info/2009/05/obtenir-les-coordonnees-gographique-dune-region/</link>
		<comments>http://www.mattk.info/2009/05/obtenir-les-coordonnees-gographique-dune-region/#comments</comments>
		<pubDate>Thu, 14 May 2009 15:05:04 +0000</pubDate>
		<dc:creator>Mattk</dc:creator>
				<category><![CDATA[Astuces]]></category>
		<category><![CDATA[Spatial Tools]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[Virtual Earth]]></category>

		<guid isPermaLink="false">http://www.mattk.info/?p=19</guid>
		<description><![CDATA[Pour les besoins d&#8217;un petit projet, il me faut les coordonnées géographique des régions administratives françaises. Le but final étant de créer des calques sur les maps Virtual Earth. Dans un premier temps, j&#8217;ai cherché un webservice qui me fournirait ces données. Pas de chances, je n&#8217;en ai pas trouvé et me suis donc rabattu]]></description>
			<content:encoded><![CDATA[<p>Pour les besoins d&#8217;un petit projet, il me faut les coordonnées géographique des régions administratives françaises. Le but final étant de créer des calques sur les maps Virtual Earth.</p>
<p>Dans un premier temps, j&#8217;ai cherché un webservice qui me fournirait ces données. Pas de chances, je n&#8217;en ai pas trouvé et me suis donc rabattu sur la solution suivante : une base données sous SQL Server 2008 contenant les calques de mes régions au format Geometry. Voici donc la méthode que j&#8217;ai utilisé.</p>
<p><strong>Etape 1 : Récupérer les régions administratives sur GEO Data Portal</strong></p>
<p>Rien de plus simple :</p>
<ol>
<li> aller sur le site : <a title="Geo Data Portal" href="http://geodata.grid.unep.ch/" target="_blank">http://geodata.grid.unep.ch/</a></li>
<li>dans le formulaire de recherche, taper le mot clé : <em>administrative boundaries</em></li>
<li> sélectionner les données : <em>Administratives Boundaries &#8211; First Level (ESRI)</em>, puis cliquer sur <em>Envoyer</em></li>
<li>une map apparaît, choisir l&#8217;onglet <em>download</em>, puis le format <em>ESRI ShapeFile</em> et lancer le téléchargement (fichier zip)</li>
</ol>
<p><strong>Etape 2 : Ajouter nos données à SQL Server 2008</strong></p>
<p>Là encore c&#8217;est easy :</p>
<ol>
<li>Télécharger les <em>SQL Spatial Tools</em> <a title="SQL Spatial Tools" href="http://www.sharpgis.net/page/SQL-Server-2008-Spatial-Tools.aspx" target="_blank">ici</a></li>
<li>Décompresser le zip contenant notre fichier ESRI Shapefile</li>
<li>Décompresser le zip des <em>SQL Spatial Tools</em> et exécuter le programme <em>Shape2SQL.exe</em></li>
<li>On rentre les données de connexion à notre BDD, puis on va chercher notre fichier .shp contenant nos shapes des régions<br />
<span style="color: #ff0000;">Important : ne pas oublier de cocher <strong>&laquo;&nbsp;Set SRID&nbsp;&raquo;</strong> avec la valeur <strong>4326</strong></span></li>
<li>Les données sont importées dans notre SQL Server 2008</li>
</ol>
<p>Tout ça, c&#8217;est bien mignon, mais je ne veux que les régions administratives françaises.</p>
<p><strong>Etape 3 : Un peu de requêtage SQL</strong></p>
<p>Pour supprimer toutes les régions, hors françaises, nous allons utiliser l&#8217;outils <em>SqlSpatial</em> fournit dans les <em>SQL Spatial Tools</em>. On lance le programme, on se connecte à notre base de données, et on vérifie que nos données soit bien présentes (nom de ma table : <em>adminbound</em>) :</p>
<div class="codecolorer-container sql default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="sql codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #993333; font-weight: bold;">SELECT</span> <span style="color: #66cc66;">*</span><br />
<span style="color: #993333; font-weight: bold;">FROM</span> adminbound</div></div>
<p>Sur la map, on peut alors voir le découpage régional administratif de tous les pays. Maintenant nous n&#8217;allons conserver que la France. Pour cela, on va créer une vue qui contiendra les ID de toutes les régions non françaises) :</p>
<div class="codecolorer-container sql default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="sql codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #993333; font-weight: bold;">CREATE</span> <span style="color: #993333; font-weight: bold;">VIEW</span> v1 <span style="color: #993333; font-weight: bold;">AS</span><br />
<span style="color: #993333; font-weight: bold;">SELECT</span> ID <span style="color: #993333; font-weight: bold;">AS</span> my_key<br />
<span style="color: #993333; font-weight: bold;">FROM</span> adminbound<br />
<span style="color: #993333; font-weight: bold;">WHERE</span> CNTRY_NAME &amp;lt;&amp;gt; <span style="color: #ff0000;">'France'</span></div></div>
<p>Puis supprimer toutes les occurences de la vue dans notre table adminbound :</p>
<div class="codecolorer-container sql default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="sql codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #993333; font-weight: bold;">DELETE</span> <span style="color: #993333; font-weight: bold;">FROM</span> adminbound<br />
<span style="color: #993333; font-weight: bold;">WHERE</span> <span style="color: #993333; font-weight: bold;">EXISTS</span> <span style="color: #66cc66;">&#40;</span><span style="color: #993333; font-weight: bold;">SELECT</span> <span style="color: #66cc66;">*</span><br />
<span style="color: #993333; font-weight: bold;">FROM</span> v1<br />
<span style="color: #993333; font-weight: bold;">WHERE</span> adminbound<span style="color: #66cc66;">.</span>ID <span style="color: #66cc66;">=</span> v1<span style="color: #66cc66;">.</span>my_key<span style="color: #66cc66;">&#41;</span></div></div>
<p>On vérifie que nous n&#8217;avons plus que la France avec une requête classique :</p>
<div class="codecolorer-container sql default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="sql codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #993333; font-weight: bold;">SELECT</span> <span style="color: #66cc66;">*</span> <span style="color: #993333; font-weight: bold;">FROM</span> adminbound</div></div>
<p>Nos régions françaises apparaissent, on peut donc supprimer la vue :</p>
<div class="codecolorer-container sql default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="sql codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #993333; font-weight: bold;">DROP</span> <span style="color: #993333; font-weight: bold;">VIEW</span> v1</div></div>
<div id="attachment_20" class="wp-caption aligncenter" style="width: 310px"><img class="size-medium wp-image-20" title="Régions Françaises" src="http://www.mattk.info/wp-content/uploads/2009/05/regionfr-300x189.png" alt="Régions Françaises" width="300" height="189" /><p class="wp-caption-text">Régions Françaises</p></div>
<p>Et voilà, il ne reste plus qu&#8217;à servir de cela pour le projet <img src='http://www.mattk.info/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p><span style="color: #008000;"><span style="color: #008080;">Mise à jour du 20/09/2009 :<br />
Il semblerait que le lien de téléchargement du fichier zip contenant les coordonnées spatiales des régions administratives (cf Etape 1) soit actuellement indisponible. En analysant un peu l&#8217;url, j&#8217;ai pu le récupérer<a title="Fichier ESRI Shapefile" href="http://geodata.grid.unep.ch/download/admin98_li_shp.zip" target="_blank"></a>. Merci Samuel pour cette remarque :</span>)</span></p>
<p><span style="color: #008000;">Mise à jour du 20/10/2009 :<br />
Le fichier est à nouveau disponible<a title="Fichier zip région administrative" href="http://geodata.grid.unep.ch/mod_download/download_geospatial.php?selectedID=290&amp;newFile=download/admin98_li_shp.zip" target="_blank"> ici</a>.</span></p>
]]></content:encoded>
			<wfw:commentRss>http://www.mattk.info/2009/05/obtenir-les-coordonnees-gographique-dune-region/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
	</channel>
</rss>
