<?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>Le blog de SQLpro &#187; index</title>
	<atom:link href="https://blog.developpez.com/sqlpro/ptag/index/feed" rel="self" type="application/rss+xml" />
	<link>https://blog.developpez.com/sqlpro</link>
	<description>Le SQL pour SQL Server, PostGreSQL et tous les autres SGBDR</description>
	<lastBuildDate>Thu, 15 Oct 2020 12:59:17 +0000</lastBuildDate>
	<language>fr-FR</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>https://wordpress.org/?v=4.1.42</generator>
	<item>
		<title>Métrique de volumétrie du stockage par table, index et partition</title>
		<link>https://blog.developpez.com/sqlpro/p13171/ms-sql-server/metrique-de-volumetrie-du-stockage-par-table-index-et-partition</link>
		<comments>https://blog.developpez.com/sqlpro/p13171/ms-sql-server/metrique-de-volumetrie-du-stockage-par-table-index-et-partition#comments</comments>
		<pubDate>Wed, 07 Feb 2018 09:19:04 +0000</pubDate>
		<dc:creator><![CDATA[SQLpro]]></dc:creator>
				<category><![CDATA[MS SQL Server]]></category>
		<category><![CDATA[SQL Server 2005]]></category>
		<category><![CDATA[SQL Server 2008]]></category>
		<category><![CDATA[SQL Server 2012]]></category>
		<category><![CDATA[SQL Server 2014]]></category>
		<category><![CDATA[SQL Server 2016]]></category>
		<category><![CDATA[SQL Server 2017]]></category>
		<category><![CDATA[index]]></category>
		<category><![CDATA[métrique]]></category>
		<category><![CDATA[partition]]></category>
		<category><![CDATA[SQL server]]></category>
		<category><![CDATA[stockage]]></category>

		<guid isPermaLink="false">http://blog.developpez.com/sqlpro/?p=789</guid>
		<description><![CDATA[Voici une petite requête complémentaire pour mesurer les volumes stockées par partition, index et tables d&#8217;une base : SELECT s.name AS TABLE_SCHEMA, o.name AS TABLE_NAME, i.name AS INDEX_NAME, &#160; &#160; &#160; &#160;fs.name AS FILEGROUP_NAME, f.name AS FILE_NAME, f.physical_name, p.partition_number, &#160; &#160; &#160; &#160;p.ROWS, p.data_compression_desc, au.total_pages * 8 AS SIZE_TOTAL_KO, &#160; &#160; &#160; &#160;SUM&#40;au.total_pages * 8&#41; [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>Voici une petite requête complémentaire pour mesurer les volumes stockées par partition, index et tables d&rsquo;une base :<br />
<span id="more-789"></span></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> s<span style="color: #66cc66;">.</span>name <span style="color: #993333; font-weight: bold;">AS</span> TABLE_SCHEMA<span style="color: #66cc66;">,</span> o<span style="color: #66cc66;">.</span>name <span style="color: #993333; font-weight: bold;">AS</span> <span style="color: #993333; font-weight: bold;">TABLE_NAME</span><span style="color: #66cc66;">,</span> i<span style="color: #66cc66;">.</span>name <span style="color: #993333; font-weight: bold;">AS</span> INDEX_NAME<span style="color: #66cc66;">,</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp;fs<span style="color: #66cc66;">.</span>name <span style="color: #993333; font-weight: bold;">AS</span> FILEGROUP_NAME<span style="color: #66cc66;">,</span> f<span style="color: #66cc66;">.</span>name <span style="color: #993333; font-weight: bold;">AS</span> FILE_NAME<span style="color: #66cc66;">,</span> f<span style="color: #66cc66;">.</span>physical_name<span style="color: #66cc66;">,</span> p<span style="color: #66cc66;">.</span>partition_number<span style="color: #66cc66;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;p<span style="color: #66cc66;">.</span><span style="color: #993333; font-weight: bold;">ROWS</span><span style="color: #66cc66;">,</span> p<span style="color: #66cc66;">.</span>data_compression_desc<span style="color: #66cc66;">,</span> au<span style="color: #66cc66;">.</span>total_pages <span style="color: #66cc66;">*</span> <span style="color: #cc66cc;">8</span> <span style="color: #993333; font-weight: bold;">AS</span> SIZE_TOTAL_KO<span style="color: #66cc66;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #993333; font-weight: bold;">SUM</span><span style="color: #66cc66;">&#40;</span>au<span style="color: #66cc66;">.</span>total_pages <span style="color: #66cc66;">*</span> <span style="color: #cc66cc;">8</span><span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">OVER</span><span style="color: #66cc66;">&#40;</span>PARTITION <span style="color: #993333; font-weight: bold;">BY</span> i<span style="color: #66cc66;">.</span>name<span style="color: #66cc66;">,</span> s<span style="color: #66cc66;">.</span>name<span style="color: #66cc66;">,</span> o<span style="color: #66cc66;">.</span>name<span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">AS</span> SIZE_TOTAL_INDEX_KO<span style="color: #66cc66;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #993333; font-weight: bold;">SUM</span><span style="color: #66cc66;">&#40;</span>au<span style="color: #66cc66;">.</span>total_pages <span style="color: #66cc66;">*</span> <span style="color: #cc66cc;">8</span><span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">OVER</span><span style="color: #66cc66;">&#40;</span>PARTITION <span style="color: #993333; font-weight: bold;">BY</span> s<span style="color: #66cc66;">.</span>name<span style="color: #66cc66;">,</span> o<span style="color: #66cc66;">.</span>name<span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">AS</span> SIZE_TOTAL_TABLE_KO<br />
<span style="color: #993333; font-weight: bold;">FROM</span> &nbsp; sys<span style="color: #66cc66;">.</span>partitions <span style="color: #993333; font-weight: bold;">AS</span> p<br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #993333; font-weight: bold;">JOIN</span> sys<span style="color: #66cc66;">.</span>allocation_units <span style="color: #993333; font-weight: bold;">AS</span> au<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #993333; font-weight: bold;">ON</span> p<span style="color: #66cc66;">.</span>hobt_id <span style="color: #66cc66;">=</span> au<span style="color: #66cc66;">.</span>container_id<br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #993333; font-weight: bold;">JOIN</span> sys<span style="color: #66cc66;">.</span>filegroups <span style="color: #993333; font-weight: bold;">AS</span> fs<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #993333; font-weight: bold;">ON</span> au<span style="color: #66cc66;">.</span>data_space_id <span style="color: #66cc66;">=</span> fs<span style="color: #66cc66;">.</span>data_space_id<br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #993333; font-weight: bold;">JOIN</span> sys<span style="color: #66cc66;">.</span>database_files <span style="color: #993333; font-weight: bold;">AS</span> f<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #993333; font-weight: bold;">ON</span> fs<span style="color: #66cc66;">.</span>data_space_id <span style="color: #66cc66;">=</span> f<span style="color: #66cc66;">.</span>file_id<br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #993333; font-weight: bold;">JOIN</span> sys<span style="color: #66cc66;">.</span>objects <span style="color: #993333; font-weight: bold;">AS</span> o<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #993333; font-weight: bold;">ON</span> p<span style="color: #66cc66;">.</span>object_id <span style="color: #66cc66;">=</span> o<span style="color: #66cc66;">.</span>object_id<br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #993333; font-weight: bold;">JOIN</span> sys<span style="color: #66cc66;">.</span>schemas <span style="color: #993333; font-weight: bold;">AS</span> s <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #993333; font-weight: bold;">ON</span> o<span style="color: #66cc66;">.</span>schema_id <span style="color: #66cc66;">=</span> s<span style="color: #66cc66;">.</span>schema_id<br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #993333; font-weight: bold;">JOIN</span> sys<span style="color: #66cc66;">.</span>indexes <span style="color: #993333; font-weight: bold;">AS</span> i<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #993333; font-weight: bold;">ON</span> p<span style="color: #66cc66;">.</span>object_id <span style="color: #66cc66;">=</span> i<span style="color: #66cc66;">.</span>object_id <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #993333; font-weight: bold;">AND</span> p<span style="color: #66cc66;">.</span>index_id <span style="color: #66cc66;">=</span> i<span style="color: #66cc66;">.</span>index_id;</div></div>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">Frédéric Brouard, alias SQLpro, ARCHITECTE DE DONNÉES<br />
Expert &nbsp;S.G.B.D &nbsp;relationnelles &nbsp; et &nbsp; langage &nbsp;S.Q.L<br />
Moste &nbsp;Valuable &nbsp;Professionnal &nbsp;Microsoft &nbsp;SQL Server<br />
Société SQLspot &nbsp;: &nbsp;modélisation, conseil, formation,<br />
optimisation, &nbsp;audit, &nbsp;tuning, &nbsp;administration &nbsp;SGBDR<br />
Enseignant: CNAM PACA, ISEN Toulon, CESI Aix en Prov.</div></div>
<p>L&rsquo;entreprise <a href="http://www.sqlspot.com">SQL Spot</a><br />
<strong>Le site web sur le </strong><a href="http://sqlpro.developpez.com/">SQL et les SGBDR</a></p>
<p><img src="http://blog.developpez.com/media/Microsoft_MVP_logo_vertical Brouard 400.jpg" width="400" height="135" alt="MVP Microsoft SQL
Server" /></p>
]]></content:encoded>
			<wfw:commentRss></wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Métadonnées de l&#8217;utilisation d&#8217;une colonne</title>
		<link>https://blog.developpez.com/sqlpro/p13155/ms-sql-server/metadonnees-de-lutilisation-dune-colonne</link>
		<comments>https://blog.developpez.com/sqlpro/p13155/ms-sql-server/metadonnees-de-lutilisation-dune-colonne#comments</comments>
		<pubDate>Mon, 23 Oct 2017 07:07:13 +0000</pubDate>
		<dc:creator><![CDATA[SQLpro]]></dc:creator>
				<category><![CDATA[MS SQL Server]]></category>
		<category><![CDATA[SQL Server 2005]]></category>
		<category><![CDATA[SQL Server 2008]]></category>
		<category><![CDATA[SQL Server 2012]]></category>
		<category><![CDATA[SQL Server 2014]]></category>
		<category><![CDATA[SQL Server 2016]]></category>
		<category><![CDATA[SQL Server 2017]]></category>
		<category><![CDATA[colonne]]></category>
		<category><![CDATA[contrainte]]></category>
		<category><![CDATA[index]]></category>
		<category><![CDATA[métadonnées]]></category>
		<category><![CDATA[sql]]></category>

		<guid isPermaLink="false">http://blog.developpez.com/sqlpro/?p=765</guid>
		<description><![CDATA[Certaines modifications de type de données d&#8217;une colonne nécessitent une suppression préalable des contraintes et index. Pour vous y aider, la procédure suivante indique dans quels objets (index ou contraintes) une colonne d&#8217;une table passée en argument est enrôlée. Dans le cas ou vous voudriez changer le type d&#8217;une telle colonne, il faudrait agir manuellement [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>Certaines modifications de type de données d&rsquo;une colonne nécessitent une suppression préalable des contraintes et index. Pour vous y aider, la procédure suivante indique dans quels objets (index ou contraintes) une colonne d&rsquo;une table passée en argument est enrôlée.<br />
<span id="more-765"></span></p>
<p>Dans le cas ou vous voudriez changer le type d&rsquo;une telle colonne, il faudrait agir manuellement avec le scénario suivant :</p>
<p>1)	Scripter la création des contraintes par clic droit sur le nom de chacune des contraintes et les supprimer<br />
2)	Scripter la création des index par clic droit sur le nom de chacun des index et les supprimer<br />
3)	Modifier le type de données de la colonne avec la commande ALTER TABLE … ALTER COLUMN …<br />
4)	Recréer les index<br />
5)	Recréer les contraintes</p>
<p>Cette procédure à été créée pour vous y aider. Elle indique pour un couple d’information table/colonne dans quels index ou contrainte cette dernière est enrôlée&#8230;<br />
Cette procédure est créée en tant que procédure système afin d&rsquo;être exploitable dans n&rsquo;importe quelle base de l&rsquo;instance SQL Server.</p>
<div class="codecolorer-container sql default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:300px;"><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;">USE</span> master;<br />
<span style="color: #993333; font-weight: bold;">GO</span><br />
<br />
<span style="color: #993333; font-weight: bold;">IF</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 />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #993333; font-weight: bold;">FROM</span> &nbsp; sys<span style="color: #66cc66;">.</span>all_objects<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #993333; font-weight: bold;">WHERE</span> &nbsp;name <span style="color: #66cc66;">=</span> <span style="color: #ff0000;">'sp__COLUMN_IS_USED'</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #993333; font-weight: bold;">AND</span> &nbsp;schema_id <span style="color: #66cc66;">=</span> SCHEMA_ID<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'dbo'</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><br />
&nbsp; &nbsp;<span style="color: #993333; font-weight: bold;">EXEC</span> <span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'ROP PROCEDURE dbo.sp__COLUMN_IS_USED;'</span><span style="color: #66cc66;">&#41;</span>;<br />
<span style="color: #993333; font-weight: bold;">GO</span><br />
<br />
<span style="color: #808080; font-style: italic;">--===========================================================================--</span><br />
<span style="color: #808080; font-style: italic;">-- METADONNÉES D'UTILISATION D'UNE COLONNE &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; --</span><br />
<span style="color: #808080; font-style: italic;">--===========================================================================--</span><br />
<span style="color: #808080; font-style: italic;">-- Fredéric Brouard alias SQLpro &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;http://sqlpro.developpez.com --</span><br />
<span style="color: #808080; font-style: italic;">-- Société SQL SPOT - http://www.sqlspot.com &nbsp; &nbsp; &nbsp; &nbsp;2017-10-13 - version 1.0 --</span><br />
<span style="color: #808080; font-style: italic;">--===========================================================================--</span><br />
<br />
<br />
<span style="color: #808080; font-style: italic;">--▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄--</span><br />
<span style="color: #808080; font-style: italic;">-- PHASE 1 : création de la procédure &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;--</span><br />
<span style="color: #808080; font-style: italic;">--▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀--</span><br />
<br />
<br />
<span style="color: #993333; font-weight: bold;">USE</span> master;<br />
<span style="color: #993333; font-weight: bold;">GO</span><br />
<br />
<span style="color: #993333; font-weight: bold;">CREATE</span> <span style="color: #993333; font-weight: bold;">PROCEDURE</span> dbo<span style="color: #66cc66;">.</span>sp__COLUMN_IS_USED @OBJ NVARCHAR<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">261</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">,</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; @COL NVARCHAR<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">128</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">=</span> <span style="color: #993333; font-weight: bold;">NULL</span><br />
<span style="color: #993333; font-weight: bold;">AS</span><br />
<span style="color: #808080; font-style: italic;">/******************************************************************************<br />
* METADONNÉES D'UTILISATION D'UNE COLONNE &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; *<br />
* Procédure listant sous forme de tables dans quels objets est utilisé une &nbsp; &nbsp;*<br />
* colonne d'une table &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; *<br />
******************************************************************************* &nbsp; <br />
* Frédéric Brouard - SQLpro@SQLspot.com - Sté SQL SPOT http://www.sqlspot.com *<br />
* Plus d'info. sur http://sqlpro.developpez.com &nbsp; - &nbsp;2017-10-13 - version 1.0 * &nbsp; <br />
******************************************************************************* &nbsp; <br />
* Cette procédure prend en argument le nom d'une table avec son schéma SQL &nbsp; &nbsp;*<br />
* (sinon le schéma par défaut de l'utilisateur qui la lance) ainsi qu'un nom &nbsp;*<br />
* de colonne et renvoie un jeu de données contenant le descriptif des cas &nbsp; &nbsp; *<br />
* d'utilisation de cette colonne dans les index et les contraintes &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*<br />
*******************************************************************************<br />
* ATTENTION &nbsp;: procédure système ! Exécutable depuis n'importe quelle base &nbsp; &nbsp;*<br />
* &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; *<br />
* Paramètre en entrée : &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; *<br />
* &nbsp; &nbsp;@OBJ type NVARCHAR(261) : nom de table dont on veut connaître les index &nbsp;*<br />
* &nbsp; &nbsp;@COL nom de la colonne dont on veut connaître l'usage &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*<br />
* &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; *<br />
* COLONNE de la table en sortie : &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; *<br />
* &nbsp; &nbsp;COLUMN_NAME &nbsp; nom de la colonne passée en paramètre &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*<br />
* &nbsp; &nbsp;OBJECT_TYPE &nbsp; type d'objet (nature de la contrainte ou INDEX) &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*<br />
* &nbsp; &nbsp;OBJECT_NAME &nbsp; nom de la contrainte ou de l'index &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; *<br />
<br />
* &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; *<br />
* EXEMPLE : &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; *<br />
* &nbsp; &nbsp;EXEC dbo.sp__COLUMN_IS_USED 'CC', 'Idx' &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*<br />
* &nbsp; &nbsp;... donne la liste de tous les index et contrainte de la table CC &nbsp; &nbsp; &nbsp; &nbsp;*<br />
* &nbsp; &nbsp; &nbsp; &nbsp;incluant la colonne Idx &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* <br />
* &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; *<br />
******************************************************************************/</span> <br />
<br />
<span style="color: #993333; font-weight: bold;">SET</span> NOCOUNT <span style="color: #993333; font-weight: bold;">ON</span>;<br />
<span style="color: #993333; font-weight: bold;">WITH</span> T <span style="color: #993333; font-weight: bold;">AS</span> <span style="color: #66cc66;">&#40;</span><br />
<span style="color: #993333; font-weight: bold;">SELECT</span> COLUMN_NAME<span style="color: #66cc66;">,</span> CONSTRAINT_TYPE <span style="color: #993333; font-weight: bold;">AS</span> OBJECT_TYPE<span style="color: #66cc66;">,</span> KCU<span style="color: #66cc66;">.</span>CONSTRAINT_NAME <span style="color: #993333; font-weight: bold;">AS</span> OBJECT_NAME <br />
<span style="color: #993333; font-weight: bold;">FROM</span> &nbsp; INFORMATION_SCHEMA<span style="color: #66cc66;">.</span>KEY_COLUMN_USAGE <span style="color: #993333; font-weight: bold;">AS</span> KCU<br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #993333; font-weight: bold;">JOIN</span> INFORMATION_SCHEMA<span style="color: #66cc66;">.</span>TABLE_CONSTRAINTS <span style="color: #993333; font-weight: bold;">AS</span> TC<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #993333; font-weight: bold;">ON</span> KCU<span style="color: #66cc66;">.</span>TABLE_SCHEMA <span style="color: #66cc66;">=</span> TC<span style="color: #66cc66;">.</span>TABLE_SCHEMA &nbsp;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #993333; font-weight: bold;">AND</span> KCU<span style="color: #66cc66;">.</span><span style="color: #993333; font-weight: bold;">TABLE_NAME</span> <span style="color: #66cc66;">=</span> TC<span style="color: #66cc66;">.</span><span style="color: #993333; font-weight: bold;">TABLE_NAME</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #993333; font-weight: bold;">AND</span> KCU<span style="color: #66cc66;">.</span>CONSTRAINT_NAME <span style="color: #66cc66;">=</span> TC<span style="color: #66cc66;">.</span>CONSTRAINT_NAME<br />
<span style="color: #993333; font-weight: bold;">WHERE</span> &nbsp;OBJECT_ID<span style="color: #66cc66;">&#40;</span>KCU<span style="color: #66cc66;">.</span>TABLE_SCHEMA <span style="color: #66cc66;">+</span> <span style="color: #ff0000;">'.'</span> <span style="color: #66cc66;">+</span> KCU<span style="color: #66cc66;">.</span><span style="color: #993333; font-weight: bold;">TABLE_NAME</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">=</span> OBJECT_ID<span style="color: #66cc66;">&#40;</span>@OBJ<span style="color: #66cc66;">&#41;</span> <br />
&nbsp; <span style="color: #993333; font-weight: bold;">AND</span> &nbsp;<span style="color: #993333; font-weight: bold;">REPLACE</span><span style="color: #66cc66;">&#40;</span><span style="color: #993333; font-weight: bold;">REPLACE</span><span style="color: #66cc66;">&#40;</span>RTRIM<span style="color: #66cc66;">&#40;</span>LTRIM<span style="color: #66cc66;">&#40;</span>@COL<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">,</span> <span style="color: #ff0000;">']'</span><span style="color: #66cc66;">,</span> <span style="color: #ff0000;">''</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">,</span> <span style="color: #ff0000;">'['</span><span style="color: #66cc66;">,</span> <span style="color: #ff0000;">''</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">=</span> COLUMN_NAME<br />
<span style="color: #993333; font-weight: bold;">UNION</span> <span style="color: #993333; font-weight: bold;">ALL</span><br />
<span style="color: #993333; font-weight: bold;">SELECT</span> <span style="color: #993333; font-weight: bold;">REPLACE</span><span style="color: #66cc66;">&#40;</span><span style="color: #993333; font-weight: bold;">REPLACE</span><span style="color: #66cc66;">&#40;</span>RTRIM<span style="color: #66cc66;">&#40;</span>LTRIM<span style="color: #66cc66;">&#40;</span>@COL<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">,</span> <span style="color: #ff0000;">']'</span><span style="color: #66cc66;">,</span> <span style="color: #ff0000;">''</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">,</span> <span style="color: #ff0000;">'['</span><span style="color: #66cc66;">,</span> <span style="color: #ff0000;">''</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">,</span> CONSTRAINT_TYPE <span style="color: #993333; font-weight: bold;">AS</span> OBJECT_TYPE<span style="color: #66cc66;">,</span> CK<span style="color: #66cc66;">.</span>CONSTRAINT_NAME <span style="color: #993333; font-weight: bold;">AS</span> OBJECT_NAME <br />
<span style="color: #993333; font-weight: bold;">FROM</span> &nbsp; INFORMATION_SCHEMA<span style="color: #66cc66;">.</span>CHECK_CONSTRAINTS <span style="color: #993333; font-weight: bold;">AS</span> CK<br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #993333; font-weight: bold;">JOIN</span> INFORMATION_SCHEMA<span style="color: #66cc66;">.</span>TABLE_CONSTRAINTS <span style="color: #993333; font-weight: bold;">AS</span> TC<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #993333; font-weight: bold;">ON</span> CK<span style="color: #66cc66;">.</span>CONSTRAINT_SCHEMA <span style="color: #66cc66;">=</span> TC<span style="color: #66cc66;">.</span>CONSTRAINT_SCHEMA &nbsp;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #993333; font-weight: bold;">AND</span> CK<span style="color: #66cc66;">.</span>CONSTRAINT_NAME <span style="color: #66cc66;">=</span> TC<span style="color: #66cc66;">.</span>CONSTRAINT_NAME<br />
<span style="color: #993333; font-weight: bold;">WHERE</span> &nbsp;OBJECT_ID<span style="color: #66cc66;">&#40;</span>TC<span style="color: #66cc66;">.</span>TABLE_SCHEMA <span style="color: #66cc66;">+</span> <span style="color: #ff0000;">'.'</span> <span style="color: #66cc66;">+</span> TC<span style="color: #66cc66;">.</span><span style="color: #993333; font-weight: bold;">TABLE_NAME</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">=</span> OBJECT_ID<span style="color: #66cc66;">&#40;</span>@OBJ<span style="color: #66cc66;">&#41;</span> <br />
&nbsp; <span style="color: #993333; font-weight: bold;">AND</span> &nbsp;CHECK_CLAUSE <span style="color: #993333; font-weight: bold;">LIKE</span> <span style="color: #ff0000;">'%'</span> <span style="color: #66cc66;">+</span> <span style="color: #993333; font-weight: bold;">REPLACE</span><span style="color: #66cc66;">&#40;</span><span style="color: #993333; font-weight: bold;">REPLACE</span><span style="color: #66cc66;">&#40;</span>RTRIM<span style="color: #66cc66;">&#40;</span>LTRIM<span style="color: #66cc66;">&#40;</span>@COL<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">,</span> <span style="color: #ff0000;">']'</span><span style="color: #66cc66;">,</span> <span style="color: #ff0000;">''</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">,</span> <span style="color: #ff0000;">'['</span><span style="color: #66cc66;">,</span> <span style="color: #ff0000;">''</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">+</span> <span style="color: #ff0000;">'%'</span><br />
<span style="color: #993333; font-weight: bold;">UNION</span> <span style="color: #993333; font-weight: bold;">ALL</span><br />
<span style="color: #993333; font-weight: bold;">SELECT</span> c<span style="color: #66cc66;">.</span>name<span style="color: #66cc66;">,</span> <span style="color: #ff0000;">'INDEX'</span><span style="color: #66cc66;">,</span> i<span style="color: #66cc66;">.</span>name <br />
<span style="color: #993333; font-weight: bold;">FROM</span> &nbsp; sys<span style="color: #66cc66;">.</span>indexes <span style="color: #993333; font-weight: bold;">AS</span> i <br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #993333; font-weight: bold;">JOIN</span> sys<span style="color: #66cc66;">.</span>index_columns <span style="color: #993333; font-weight: bold;">AS</span> ic <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #993333; font-weight: bold;">ON</span> i<span style="color: #66cc66;">.</span>object_id <span style="color: #66cc66;">=</span> ic<span style="color: #66cc66;">.</span>object_id <span style="color: #993333; font-weight: bold;">AND</span> i<span style="color: #66cc66;">.</span>index_id <span style="color: #66cc66;">=</span> ic<span style="color: #66cc66;">.</span>index_id <br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #993333; font-weight: bold;">JOIN</span> sys<span style="color: #66cc66;">.</span><span style="color: #993333; font-weight: bold;">COLUMNS</span> <span style="color: #993333; font-weight: bold;">AS</span> c <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #993333; font-weight: bold;">ON</span> ic<span style="color: #66cc66;">.</span>object_id <span style="color: #66cc66;">=</span> c<span style="color: #66cc66;">.</span>object_id <span style="color: #993333; font-weight: bold;">AND</span> ic<span style="color: #66cc66;">.</span>column_id <span style="color: #66cc66;">=</span> c<span style="color: #66cc66;">.</span>column_id<br />
<span style="color: #993333; font-weight: bold;">WHERE</span> &nbsp;i<span style="color: #66cc66;">.</span>object_id <span style="color: #66cc66;">=</span> OBJECT_ID<span style="color: #66cc66;">&#40;</span>@OBJ<span style="color: #66cc66;">&#41;</span> <br />
&nbsp; <span style="color: #993333; font-weight: bold;">AND</span> &nbsp;<span style="color: #993333; font-weight: bold;">REPLACE</span><span style="color: #66cc66;">&#40;</span><span style="color: #993333; font-weight: bold;">REPLACE</span><span style="color: #66cc66;">&#40;</span>RTRIM<span style="color: #66cc66;">&#40;</span>LTRIM<span style="color: #66cc66;">&#40;</span>@COL<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">,</span> <span style="color: #ff0000;">']'</span><span style="color: #66cc66;">,</span> <span style="color: #ff0000;">''</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">,</span> <span style="color: #ff0000;">'['</span><span style="color: #66cc66;">,</span> <span style="color: #ff0000;">''</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">=</span> c<span style="color: #66cc66;">.</span>name<span style="color: #66cc66;">&#41;</span><br />
<span style="color: #993333; font-weight: bold;">SELECT</span> <span style="color: #66cc66;">*</span><br />
<span style="color: #993333; font-weight: bold;">FROM</span> &nbsp; T<br />
<span style="color: #993333; font-weight: bold;">ORDER</span> <span style="color: #993333; font-weight: bold;">BY</span> <span style="color: #993333; font-weight: bold;">CASE</span> OBJECT_TYPE <span style="color: #993333; font-weight: bold;">WHEN</span> <span style="color: #ff0000;">'PRIMARY KEY'</span> <span style="color: #993333; font-weight: bold;">THEN</span> <span style="color: #cc66cc;">1</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #993333; font-weight: bold;">WHEN</span> <span style="color: #ff0000;">'UNIQUE'</span> <span style="color: #993333; font-weight: bold;">THEN</span> <span style="color: #cc66cc;">2</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #993333; font-weight: bold;">WHEN</span> <span style="color: #ff0000;">'FOREIGN KEY'</span> <span style="color: #993333; font-weight: bold;">THEN</span> <span style="color: #cc66cc;">3</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #993333; font-weight: bold;">WHEN</span> <span style="color: #ff0000;">'CHECK'</span> <span style="color: #993333; font-weight: bold;">THEN</span> <span style="color: #cc66cc;">4</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #993333; font-weight: bold;">WHEN</span> <span style="color: #ff0000;">'INDEX'</span> <span style="color: #993333; font-weight: bold;">THEN</span> <span style="color: #cc66cc;">5</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #993333; font-weight: bold;">ELSE</span> <span style="color: #cc66cc;">99</span> <span style="color: #993333; font-weight: bold;">END</span><span style="color: #66cc66;">,</span> OBJECT_NAME; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br />
<span style="color: #993333; font-weight: bold;">GO</span><br />
<br />
<br />
<span style="color: #808080; font-style: italic;">--▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄--</span><br />
<span style="color: #808080; font-style: italic;">-- PHASE 2 : traduction en procédure système &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; --</span><br />
<span style="color: #808080; font-style: italic;">--▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀--</span><br />
<br />
<span style="color: #993333; font-weight: bold;">EXEC</span> sp_MS_marksystemobject <span style="color: #ff0000;">'sp__COLUMN_IS_USED'</span>;</div></div>
<p>Pour utiliser cette procédure, lancez la avec EXEC et passez le nom de table éventuellement préfixé par son schéma SQL ainsi que le nom de la colonne. Exemple :</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">EXEC sp__COLUMN_IS_USED 'matable', 'macolonne';</div></div>
<p><a href="http://sqlpro.developpez.com/_fichierSQL/sp__COLUMN_IS_USED.txt" title="CODE SQL" rel="noopener" target="_blank">LE CODE ! LE CODE ! LE CODE ! LE CODE ! LE CODE ! LE CODE ! LE CODE ! LE CODE ! LE CODE ! LE CODE !</a></p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">Frédéric Brouard, alias SQLpro, ARCHITECTE DE DONNÉES<br />
Expert &nbsp;S.G.B.D &nbsp;relationnelles &nbsp; et &nbsp; langage &nbsp;S.Q.L<br />
Moste &nbsp;Valuable &nbsp;Professionnal &nbsp;Microsoft &nbsp;SQL Server<br />
Société SQLspot &nbsp;: &nbsp;modélisation, conseil, formation,<br />
optimisation, &nbsp;audit, &nbsp;tuning, &nbsp;administration &nbsp;SGBDR<br />
Enseignant: CNAM PACA, ISEN Toulon, CESI Aix en Prov.</div></div>
<p>L&rsquo;entreprise <a href="http://www.sqlspot.com">SQL Spot</a><br />
<strong>Le site web sur le </strong><a href="http://sqlpro.developpez.com/">SQL et les SGBDR</a></p>
<p><img src="http://blog.developpez.com/media/Microsoft_MVP_logo_vertical Brouard 400.jpg" width="400" height="135" alt="MVP Microsoft SQL
Server" /></p>
<div id="attachment_590" style="width: 548px" class="wp-caption alignnone"><a href="http://blog.developpez.com/sqlpro/files/2015/09/Couverture-livre-SQL-server-Eyrolles.jpg"><img src="http://blog.developpez.com/sqlpro/files/2015/09/Couverture-livre-SQL-server-Eyrolles.jpg" alt="Développez et administrez pour la performance avec SQL Server 2014" width="538" height="652" class="size-full wp-image-590" /></a><p class="wp-caption-text">Développez et administrez pour la performance avec SQL Server 2014</p></div>
]]></content:encoded>
			<wfw:commentRss></wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Métadonnées des index (sp__helpindex)</title>
		<link>https://blog.developpez.com/sqlpro/p13139/ms-sql-server/sql-server-2012/metadonnees-des-index-sp__helpindex</link>
		<comments>https://blog.developpez.com/sqlpro/p13139/ms-sql-server/sql-server-2012/metadonnees-des-index-sp__helpindex#comments</comments>
		<pubDate>Tue, 17 Jan 2017 15:51:08 +0000</pubDate>
		<dc:creator><![CDATA[SQLpro]]></dc:creator>
				<category><![CDATA[SQL Server 2012]]></category>
		<category><![CDATA[SQL Server 2014]]></category>
		<category><![CDATA[SQL Server 2016]]></category>
		<category><![CDATA[descriptif]]></category>
		<category><![CDATA[index]]></category>
		<category><![CDATA[métadonnée]]></category>
		<category><![CDATA[sp_helpindex]]></category>
		<category><![CDATA[SQL server]]></category>

		<guid isPermaLink="false">http://blog.developpez.com/sqlpro/?p=744</guid>
		<description><![CDATA[La procédure stockée master.sys.sp_helpindex, décrivant les index d&#8217;une table, fournit par Microsoft, est aujourd&#8217;hui fortement obsolète et Microsoft n&#8217;a pas souhaité donné suite aux demandes de modification (1). Voici une procédure inspirée de cette dernière bien plus complète et prenant en compte tous les types d&#8217;index (spatiaux, XML, columstore, fulltext). (1) Dans l&#8217;outil CONNECT consacré [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>La procédure stockée master.sys.sp_helpindex, décrivant les index d&rsquo;une table, fournit par Microsoft, est aujourd&rsquo;hui fortement obsolète et Microsoft n&rsquo;a pas souhaité donné suite aux demandes de modification (1). Voici une procédure inspirée de cette dernière bien plus complète et prenant en compte tous les types d&rsquo;index (spatiaux, XML, columstore, fulltext).<br />
<span id="more-744"></span><br />
<strong>(1)</strong> Dans l&rsquo;outil CONNECT consacré aux amélioration de SQL Server, il est dit par Microsoft, que, malgré les multiples demandes, la procédure stockée <a href="https://connect.microsoft.com/SQLServer/feedback/details/577526/sp-helpindex-to-show-included-columns" title="CONNECT : sp_helpindex, demande d'amélioration fermées" target="_blank">sp_helpindex</a>, ne sera pas améliorée&#8230;<br />
Cependant cette procédure est bien pratique pour comparer les index d&rsquo;une même table afin de savoir s&rsquo;il n&rsquo;existe pas déjà tel ou tel index, au moment d&rsquo;en créer de nouveaux, ou encore, s&rsquo;il existe des index inclus ou redondants.<br />
Voici donc une nouvelle procédure intitulée sp__helpindex (notez le double blanc souligné afin de ne pas écraser l&rsquo;ancienne) qui permet de pallier à la déficience de l&rsquo;ancienne et qui rajoute :</p>
<ul>
<li>d&rsquo;un point de vu &laquo;&nbsp;horizontal&nbsp;&raquo; : nom de table, colonnes incluses, filtre et l&rsquo;essentiel de la clause WITH</li>
<li>d&rsquo;un point de vue vertical : les index columnstore, xml, spatiaux et fulltext</li>
</ul>
<p><strong>Voici le code de cette procédure :</strong></p>
<div class="codecolorer-container sql default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:300px;"><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;">PROCEDURE</span> dbo<span style="color: #66cc66;">.</span>sp__HELPINDEX @OBJ NVARCHAR<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">133</span><span style="color: #66cc66;">&#41;</span> <br />
<span style="color: #993333; font-weight: bold;">AS</span><br />
<span style="color: #808080; font-style: italic;">/******************************************************************************<br />
* METADONNÉES DES INDEX &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; *<br />
* Procédure listant sous forme de tables les métadonnées logique des index &nbsp; &nbsp;*<br />
******************************************************************************* &nbsp; <br />
* Frédéric Brouard - SQLpro@SQLspot.com - Sté SQL SPOT http://www.sqlspot.com *<br />
* Plus d'info. sur http://sqlpro.developpez.com &nbsp; - &nbsp;2017-01-17 - version 1.0 * &nbsp; <br />
******************************************************************************* &nbsp; <br />
* Cette procédure prend en argument le nom d'une table avec son schéma SQL &nbsp; &nbsp;*<br />
* (sinon le schéma par défaut de l'utilisateur qui la lance) et renvoie un &nbsp; &nbsp;*<br />
* jeu de données contenant le descriptif logique de constitution d'un index &nbsp; *<br />
* ou de tous les index de la base &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; *<br />
* NOTA substitut à la procédure stockée système sp_helpindex &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*<br />
*******************************************************************************<br />
* ATTENTION &nbsp;: procédure système ! Exécutable depuis n'importe quelle base &nbsp; &nbsp;*<br />
* &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; *<br />
* Paramètre en entrée : &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; *<br />
* &nbsp; &nbsp;@OBJ type NVARCHAR(133) : nom de table dont on veut connaître les index &nbsp;*<br />
* &nbsp; &nbsp; &nbsp; si vide, la procédure renvoie la liste de tous les index &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*<br />
* &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; *<br />
* COLONNE de la table en sortie : &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; *<br />
* &nbsp; &nbsp;TABLE_NAME : nom de la table en deux parties (schéma SQL + nom) &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*<br />
* &nbsp; &nbsp;INDEX_NAME : nom de l'index (1) &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*<br />
* &nbsp; &nbsp;INDEX TYPE : type d'index &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*<br />
* &nbsp; &nbsp;INDEX_STORAGE : type et nom de l'espace de stockage &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*<br />
* &nbsp; &nbsp;INDEX_KEY : liste des colonnes composant la clef d'index (2) &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; *<br />
* &nbsp; &nbsp;INDEX_INCLUDE : liste des colonnes incluses (3) &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*<br />
* &nbsp; &nbsp;INDEX_FILTER : filtre d'index s'il y a lieu &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*<br />
* &nbsp; &nbsp;INDEX_WITH : principaux paramètres de la clause WITH &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; *<br />
* &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; *<br />
* NOTA : &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*<br />
* &nbsp; (1) certains index n'ont pas de nom. C'est le cas des index &quot;fulltext&quot; &nbsp; &nbsp;*<br />
* &nbsp; (2) certains index n'ont pas de clef. C'est le cas des index &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*<br />
* &nbsp; &nbsp; &nbsp; &quot;columnstore&quot; et &quot;fulltext&quot;. Dans ce cas les colonnes indexées &nbsp; &nbsp; &nbsp; &nbsp;*<br />
* &nbsp; &nbsp; &nbsp; figurent dans la clause INDEX_INCLUDE &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; *<br />
* &nbsp; (3) pour les index CLUSTERED de type BTree, toutes les colonnes autre &nbsp; &nbsp; *<br />
* &nbsp; &nbsp; &nbsp; que celles de la clef étant présente, la valeur présentée est : &nbsp; &nbsp; &nbsp; *<br />
* &nbsp; &nbsp; &nbsp; * - (INDEX_KEY) &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; *<br />
* &nbsp; &nbsp; &nbsp; pour les index CLUSTERED COLUMNSTORE toutes les colonnes de la table &nbsp;*<br />
* &nbsp; &nbsp; &nbsp; étant présente, la valeur présentée est : * &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; *<br />
* &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; *<br />
* EXEMPLE : &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; *<br />
* &nbsp; &nbsp;EXEC dbo.sp__HELPINDEX NULL &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*<br />
* &nbsp; &nbsp;... donne la liste de tous les index de la base ... &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* <br />
* &nbsp; &nbsp;EXEC dbo.sp__HELPINDEX &nbsp;'[client]' &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; *<br />
* &nbsp; &nbsp;... donne la liste des index de la table client ... &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* <br />
* &nbsp; &nbsp;EXEC dbo.sp__HELPINDEX &nbsp;'ventes.client' &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*<br />
* &nbsp; &nbsp;... donne la liste des index de la table client du schéma SQL vente... &nbsp; * <br />
* &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; *<br />
******************************************************************************/</span> <br />
<br />
<span style="color: #993333; font-weight: bold;">SET</span> NOCOUNT <span style="color: #993333; font-weight: bold;">ON</span>;<br />
<span style="color: #993333; font-weight: bold;">WITH</span> <br />
T0 <span style="color: #993333; font-weight: bold;">AS</span> <br />
<span style="color: #66cc66;">&#40;</span><br />
<span style="color: #993333; font-weight: bold;">SELECT</span> i<span style="color: #66cc66;">.</span><span style="color: #ff0000;">&quot;type&quot;</span><span style="color: #66cc66;">,</span> s<span style="color: #66cc66;">.</span>name <span style="color: #66cc66;">+</span> <span style="color: #ff0000;">'.'</span> <span style="color: #66cc66;">+</span> o<span style="color: #66cc66;">.</span>name <span style="color: #993333; font-weight: bold;">AS</span> <span style="color: #993333; font-weight: bold;">TABLE_NAME</span><span style="color: #66cc66;">,</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp;i<span style="color: #66cc66;">.</span>name <span style="color: #993333; font-weight: bold;">AS</span> INDEX_NAME<span style="color: #66cc66;">,</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #993333; font-weight: bold;">CASE</span> <span style="color: #993333; font-weight: bold;">WHEN</span> i<span style="color: #66cc66;">.</span>is_unique <span style="color: #66cc66;">=</span> <span style="color: #cc66cc;">1</span> <span style="color: #993333; font-weight: bold;">THEN</span> <span style="color: #ff0000;">'UNIQUE '</span> <span style="color: #993333; font-weight: bold;">ELSE</span> <span style="color: #ff0000;">''</span> <span style="color: #993333; font-weight: bold;">END</span> <span style="color: #66cc66;">+</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #993333; font-weight: bold;">CASE</span> <span style="color: #993333; font-weight: bold;">WHEN</span> xi<span style="color: #66cc66;">.</span>xml_index_type <span style="color: #66cc66;">=</span> <span style="color: #cc66cc;">0</span> <span style="color: #993333; font-weight: bold;">THEN</span> <span style="color: #ff0000;">'PRIMARY '</span> <span style="color: #993333; font-weight: bold;">ELSE</span> <span style="color: #ff0000;">''</span> <span style="color: #993333; font-weight: bold;">END</span> <span style="color: #66cc66;">+</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;i<span style="color: #66cc66;">.</span>type_desc <span style="color: #66cc66;">+</span> <span style="color: #993333; font-weight: bold;">CASE</span> <span style="color: #993333; font-weight: bold;">WHEN</span> xi<span style="color: #66cc66;">.</span>xml_index_type <span style="color: #66cc66;">&gt;</span> <span style="color: #cc66cc;">0</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #993333; font-weight: bold;">THEN</span> <span style="color: #ff0000;">' FOR '</span> <span style="color: #66cc66;">+</span> xi<span style="color: #66cc66;">.</span>secondary_type_desc <span style="color: #993333; font-weight: bold;">ELSE</span> <span style="color: #ff0000;">''</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #993333; font-weight: bold;">END</span> <span style="color: #993333; font-weight: bold;">AS</span> INDEX_TYPE<span style="color: #66cc66;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #993333; font-weight: bold;">COALESCE</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'FILEGROUP: '</span> <span style="color: #66cc66;">+</span> fg<span style="color: #66cc66;">.</span>name<span style="color: #66cc66;">,</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0000;">'PARTITION: '</span> <span style="color: #66cc66;">+</span> ps<span style="color: #66cc66;">.</span>name <span style="color: #993333; font-weight: bold;">COLLATE</span> database_default <span style="color: #66cc66;">+</span><span style="color: #ff0000;">'('</span> &nbsp;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">+</span> STUFF<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#40;</span><span style="color: #993333; font-weight: bold;">SELECT</span> N<span style="color: #ff0000;">', '</span> <span style="color: #66cc66;">+</span> cp<span style="color: #66cc66;">.</span>name &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #993333; font-weight: bold;">FROM</span> &nbsp; sys<span style="color: #66cc66;">.</span>index_columns <span style="color: #993333; font-weight: bold;">AS</span> icp<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #993333; font-weight: bold;">LEFT</span> <span style="color: #993333; font-weight: bold;">OUTER</span> <span style="color: #993333; font-weight: bold;">JOIN</span> sys<span style="color: #66cc66;">.</span><span style="color: #993333; font-weight: bold;">COLUMNS</span> <span style="color: #993333; font-weight: bold;">AS</span> cp<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #993333; font-weight: bold;">ON</span> icp<span style="color: #66cc66;">.</span>object_id <span style="color: #66cc66;">=</span> cp<span style="color: #66cc66;">.</span>object_id<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #993333; font-weight: bold;">AND</span> icp<span style="color: #66cc66;">.</span>column_id <span style="color: #66cc66;">=</span> cp<span style="color: #66cc66;">.</span>column_id <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #993333; font-weight: bold;">WHERE</span> &nbsp;icp<span style="color: #66cc66;">.</span>object_id <span style="color: #66cc66;">=</span> i<span style="color: #66cc66;">.</span>object_id<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #993333; font-weight: bold;">AND</span> icp<span style="color: #66cc66;">.</span>index_id <span style="color: #66cc66;">=</span> i<span style="color: #66cc66;">.</span>index_id &nbsp;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #993333; font-weight: bold;">AND</span> icp<span style="color: #66cc66;">.</span>partition_ordinal <span style="color: #66cc66;">&gt;=</span> <span style="color: #cc66cc;">1</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #993333; font-weight: bold;">ORDER</span> &nbsp;<span style="color: #993333; font-weight: bold;">BY</span> icp<span style="color: #66cc66;">.</span>partition_ordinal &nbsp; &nbsp;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #993333; font-weight: bold;">FOR</span> XML PATH<span style="color: #66cc66;">&#40;</span>N<span style="color: #ff0000;">''</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">,</span> <span style="color: #cc66cc;">1</span><span style="color: #66cc66;">,</span> <span style="color: #cc66cc;">1</span><span style="color: #66cc66;">,</span><span style="color: #ff0000;">''</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">+</span><span style="color: #ff0000;">')'</span> <span style="color: #66cc66;">&#41;</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #993333; font-weight: bold;">AS</span> INDEX_STORAGE<span style="color: #66cc66;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;LTRIM<span style="color: #66cc66;">&#40;</span>STUFF<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#40;</span><span style="color: #993333; font-weight: bold;">SELECT</span> N<span style="color: #ff0000;">', '</span> &nbsp;<span style="color: #66cc66;">+</span> CONCAT<span style="color: #66cc66;">&#40;</span>c<span style="color: #66cc66;">.</span>name<span style="color: #66cc66;">,</span> <span style="color: #ff0000;">' '</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">+</span> <span style="color: #993333; font-weight: bold;">CASE</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #993333; font-weight: bold;">WHEN</span> i<span style="color: #66cc66;">.</span>type_desc <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #993333; font-weight: bold;">IN</span> <span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'XML'</span><span style="color: #66cc66;">,</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0000;">'SPATIAL'</span><span style="color: #66cc66;">,</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0000;">'COLUMNSTORE'</span><span style="color: #66cc66;">&#41;</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #993333; font-weight: bold;">THEN</span> <span style="color: #ff0000;">''</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #993333; font-weight: bold;">WHEN</span> is_descending_key <span style="color: #66cc66;">=</span> <span style="color: #cc66cc;">1</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #993333; font-weight: bold;">THEN</span> <span style="color: #ff0000;">'DESC'</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #993333; font-weight: bold;">WHEN</span> is_descending_key <span style="color: #66cc66;">=</span> <span style="color: #cc66cc;">0</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #993333; font-weight: bold;">THEN</span> <span style="color: #ff0000;">'ASC'</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #993333; font-weight: bold;">ELSE</span> <span style="color: #ff0000;">''</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #993333; font-weight: bold;">END</span><span style="color: #66cc66;">&#41;</span> &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #993333; font-weight: bold;">FROM</span> &nbsp; sys<span style="color: #66cc66;">.</span>index_columns <span style="color: #993333; font-weight: bold;">AS</span> ic <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #993333; font-weight: bold;">JOIN</span> sys<span style="color: #66cc66;">.</span><span style="color: #993333; font-weight: bold;">COLUMNS</span> <span style="color: #993333; font-weight: bold;">AS</span> c <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #993333; font-weight: bold;">ON</span> ic<span style="color: #66cc66;">.</span>object_id <span style="color: #66cc66;">=</span> c<span style="color: #66cc66;">.</span>object_id <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #993333; font-weight: bold;">AND</span> ic<span style="color: #66cc66;">.</span>column_id <span style="color: #66cc66;">=</span> c<span style="color: #66cc66;">.</span>column_id<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #993333; font-weight: bold;">WHERE</span> &nbsp;ic<span style="color: #66cc66;">.</span>object_id <span style="color: #66cc66;">=</span> i<span style="color: #66cc66;">.</span>object_id <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #993333; font-weight: bold;">AND</span> &nbsp;ic<span style="color: #66cc66;">.</span>index_id <span style="color: #66cc66;">=</span> i<span style="color: #66cc66;">.</span>index_id <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #993333; font-weight: bold;">AND</span> &nbsp;is_included_column <span style="color: #66cc66;">=</span> <span style="color: #cc66cc;">0</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #993333; font-weight: bold;">ORDER</span> &nbsp;<span style="color: #993333; font-weight: bold;">BY</span> key_ordinal &nbsp; &nbsp;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #993333; font-weight: bold;">FOR</span> XML PATH<span style="color: #66cc66;">&#40;</span>N<span style="color: #ff0000;">''</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">,</span> <span style="color: #cc66cc;">1</span><span style="color: #66cc66;">,</span> <span style="color: #cc66cc;">1</span><span style="color: #66cc66;">,</span><span style="color: #ff0000;">''</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">AS</span> INDEX_KEY<span style="color: #66cc66;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;LTRIM<span style="color: #66cc66;">&#40;</span>STUFF<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#40;</span><span style="color: #993333; font-weight: bold;">SELECT</span> N<span style="color: #ff0000;">', '</span> <span style="color: #66cc66;">+</span> c<span style="color: #66cc66;">.</span>name &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #993333; font-weight: bold;">FROM</span> &nbsp; sys<span style="color: #66cc66;">.</span>index_columns <span style="color: #993333; font-weight: bold;">AS</span> ic <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #993333; font-weight: bold;">JOIN</span> sys<span style="color: #66cc66;">.</span><span style="color: #993333; font-weight: bold;">COLUMNS</span> <span style="color: #993333; font-weight: bold;">AS</span> c <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #993333; font-weight: bold;">ON</span> ic<span style="color: #66cc66;">.</span>object_id <span style="color: #66cc66;">=</span> c<span style="color: #66cc66;">.</span>object_id <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #993333; font-weight: bold;">AND</span> ic<span style="color: #66cc66;">.</span>column_id <span style="color: #66cc66;">=</span> c<span style="color: #66cc66;">.</span>column_id<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #993333; font-weight: bold;">WHERE</span> &nbsp;ic<span style="color: #66cc66;">.</span>object_id <span style="color: #66cc66;">=</span> i<span style="color: #66cc66;">.</span>object_id <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #993333; font-weight: bold;">AND</span> &nbsp;ic<span style="color: #66cc66;">.</span>index_id <span style="color: #66cc66;">=</span> i<span style="color: #66cc66;">.</span>index_id <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #993333; font-weight: bold;">AND</span> &nbsp;is_included_column <span style="color: #66cc66;">=</span> <span style="color: #cc66cc;">1</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #993333; font-weight: bold;">ORDER</span> &nbsp;<span style="color: #993333; font-weight: bold;">BY</span> c<span style="color: #66cc66;">.</span>name &nbsp; &nbsp;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #993333; font-weight: bold;">FOR</span> XML PATH<span style="color: #66cc66;">&#40;</span>N<span style="color: #ff0000;">''</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">,</span> <span style="color: #cc66cc;">1</span><span style="color: #66cc66;">,</span> <span style="color: #cc66cc;">1</span><span style="color: #66cc66;">,</span><span style="color: #ff0000;">''</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">AS</span> INDEX_INCLUDE<span style="color: #66cc66;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;i<span style="color: #66cc66;">.</span>filter_definition <span style="color: #993333; font-weight: bold;">AS</span> INDEX_FILTER<span style="color: #66cc66;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #ff0000;">'FILL_FACTOR = '</span> &nbsp; &nbsp; &nbsp;<span style="color: #66cc66;">+</span> <span style="color: #993333; font-weight: bold;">CAST</span><span style="color: #66cc66;">&#40;</span>i<span style="color: #66cc66;">.</span>fill_factor <span style="color: #993333; font-weight: bold;">AS</span> <span style="color: #993333; font-weight: bold;">VARCHAR</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">32</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">+</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #ff0000;">', PAD_INDEX = '</span> &nbsp; &nbsp; &nbsp;<span style="color: #66cc66;">+</span> <span style="color: #993333; font-weight: bold;">CAST</span><span style="color: #66cc66;">&#40;</span>i<span style="color: #66cc66;">.</span>is_padded <span style="color: #993333; font-weight: bold;">AS</span> <span style="color: #993333; font-weight: bold;">CHAR</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">+</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #ff0000;">', ALLOW_ROWLOCK = '</span> &nbsp;<span style="color: #66cc66;">+</span> <span style="color: #993333; font-weight: bold;">CAST</span><span style="color: #66cc66;">&#40;</span>i<span style="color: #66cc66;">.</span>allow_row_locks <span style="color: #993333; font-weight: bold;">AS</span> <span style="color: #993333; font-weight: bold;">CHAR</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">+</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #ff0000;">', ALLOW_PAGELOCK = '</span> <span style="color: #66cc66;">+</span> <span style="color: #993333; font-weight: bold;">CAST</span><span style="color: #66cc66;">&#40;</span>i<span style="color: #66cc66;">.</span>allow_page_locks <span style="color: #993333; font-weight: bold;">AS</span> <span style="color: #993333; font-weight: bold;">CHAR</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> &nbsp;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #993333; font-weight: bold;">AS</span> INDEX_WITH<br />
<span style="color: #993333; font-weight: bold;">FROM</span> &nbsp; sys<span style="color: #66cc66;">.</span>indexes <span style="color: #993333; font-weight: bold;">AS</span> i<br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #993333; font-weight: bold;">JOIN</span> sys<span style="color: #66cc66;">.</span>objects <span style="color: #993333; font-weight: bold;">AS</span> o<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #993333; font-weight: bold;">ON</span> i<span style="color: #66cc66;">.</span>object_id <span style="color: #66cc66;">=</span> o<span style="color: #66cc66;">.</span>object_id<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #993333; font-weight: bold;">JOIN</span> sys<span style="color: #66cc66;">.</span>schemas &nbsp;<span style="color: #993333; font-weight: bold;">AS</span> s &nbsp;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #993333; font-weight: bold;">ON</span> o<span style="color: #66cc66;">.</span>schema_id <span style="color: #66cc66;">=</span> s<span style="color: #66cc66;">.</span>schema_id<br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #993333; font-weight: bold;">JOIN</span> sys<span style="color: #66cc66;">.</span>data_spaces <span style="color: #993333; font-weight: bold;">AS</span> ds<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #993333; font-weight: bold;">ON</span> i<span style="color: #66cc66;">.</span>data_space_id <span style="color: #66cc66;">=</span> ds<span style="color: #66cc66;">.</span>data_space_id<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #993333; font-weight: bold;">LEFT</span> <span style="color: #993333; font-weight: bold;">OUTER</span> <span style="color: #993333; font-weight: bold;">JOIN</span> sys<span style="color: #66cc66;">.</span>filegroups <span style="color: #993333; font-weight: bold;">AS</span> fg<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #993333; font-weight: bold;">ON</span> ds<span style="color: #66cc66;">.</span>data_space_id <span style="color: #66cc66;">=</span> fg<span style="color: #66cc66;">.</span>data_space_id <span style="color: #993333; font-weight: bold;">AND</span> ds<span style="color: #66cc66;">.</span><span style="color: #ff0000;">&quot;type&quot;</span> <span style="color: #66cc66;">=</span> <span style="color: #ff0000;">'FG'</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #993333; font-weight: bold;">LEFT</span> <span style="color: #993333; font-weight: bold;">OUTER</span> <span style="color: #993333; font-weight: bold;">JOIN</span> sys<span style="color: #66cc66;">.</span>partition_schemes <span style="color: #993333; font-weight: bold;">AS</span> ps<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #993333; font-weight: bold;">ON</span> ds<span style="color: #66cc66;">.</span>data_space_id <span style="color: #66cc66;">=</span> ps<span style="color: #66cc66;">.</span>data_space_id <span style="color: #993333; font-weight: bold;">AND</span> ds<span style="color: #66cc66;">.</span><span style="color: #ff0000;">&quot;type&quot;</span> <span style="color: #66cc66;">=</span> <span style="color: #ff0000;">'PS'</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #993333; font-weight: bold;">LEFT</span> <span style="color: #993333; font-weight: bold;">OUTER</span> <span style="color: #993333; font-weight: bold;">JOIN</span> sys<span style="color: #66cc66;">.</span>partition_functions <span style="color: #993333; font-weight: bold;">AS</span> pf<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #993333; font-weight: bold;">ON</span> ps<span style="color: #66cc66;">.</span>function_id <span style="color: #66cc66;">=</span> pf<span style="color: #66cc66;">.</span>function_id<br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #993333; font-weight: bold;">LEFT</span> <span style="color: #993333; font-weight: bold;">OUTER</span> <span style="color: #993333; font-weight: bold;">JOIN</span> sys<span style="color: #66cc66;">.</span>xml_indexes <span style="color: #993333; font-weight: bold;">AS</span> xi<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #993333; font-weight: bold;">ON</span> i<span style="color: #66cc66;">.</span>object_id <span style="color: #66cc66;">=</span> xi<span style="color: #66cc66;">.</span>object_id<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #993333; font-weight: bold;">AND</span> i<span style="color: #66cc66;">.</span>index_id <span style="color: #66cc66;">=</span> xi<span style="color: #66cc66;">.</span>index_id<br />
<span style="color: #993333; font-weight: bold;">WHERE</span> &nbsp;o<span style="color: #66cc66;">.</span>object_id <span style="color: #66cc66;">=</span> <span style="color: #993333; font-weight: bold;">COALESCE</span><span style="color: #66cc66;">&#40;</span><span style="color: #993333; font-weight: bold;">NULLIF</span><span style="color: #66cc66;">&#40;</span>OBJECT_ID<span style="color: #66cc66;">&#40;</span>@OBJ<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">,</span> <span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">,</span> o<span style="color: #66cc66;">.</span>object_id<span style="color: #66cc66;">&#41;</span><br />
<span style="color: #993333; font-weight: bold;">AND</span> &nbsp; &nbsp;i<span style="color: #66cc66;">.</span>index_id <span style="color: #66cc66;">&gt;</span> <span style="color: #cc66cc;">0</span><br />
<span style="color: #993333; font-weight: bold;">AND</span> &nbsp; &nbsp;o<span style="color: #66cc66;">.</span>is_ms_shipped <span style="color: #66cc66;">=</span> <span style="color: #cc66cc;">0</span><br />
<span style="color: #66cc66;">&#41;</span><br />
<span style="color: #993333; font-weight: bold;">SELECT</span> <span style="color: #993333; font-weight: bold;">TABLE_NAME</span><span style="color: #66cc66;">,</span> INDEX_NAME<span style="color: #66cc66;">,</span> INDEX_TYPE<span style="color: #66cc66;">,</span> INDEX_STORAGE<span style="color: #66cc66;">,</span> INDEX_KEY<span style="color: #66cc66;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #993333; font-weight: bold;">CASE</span> <span style="color: #ff0000;">&quot;type&quot;</span> <span style="color: #993333; font-weight: bold;">WHEN</span> <span style="color: #cc66cc;">1</span> <span style="color: #993333; font-weight: bold;">THEN</span> <span style="color: #ff0000;">'* - (INDEX_KEY)'</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #993333; font-weight: bold;">WHEN</span> <span style="color: #cc66cc;">5</span> <span style="color: #993333; font-weight: bold;">THEN</span> <span style="color: #ff0000;">'*'</span> <span style="color: #993333; font-weight: bold;">END</span> <span style="color: #993333; font-weight: bold;">AS</span> INDEX_INCLUDE<span style="color: #66cc66;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;INDEX_FILTER<span style="color: #66cc66;">,</span> INDEX_WITH<br />
<span style="color: #993333; font-weight: bold;">FROM</span> &nbsp; T0<br />
<span style="color: #993333; font-weight: bold;">UNION</span> <span style="color: #993333; font-weight: bold;">ALL</span><br />
<span style="color: #993333; font-weight: bold;">SELECT</span> s<span style="color: #66cc66;">.</span>name <span style="color: #66cc66;">+</span> <span style="color: #ff0000;">'.'</span> <span style="color: #66cc66;">+</span> o<span style="color: #66cc66;">.</span>name <span style="color: #993333; font-weight: bold;">AS</span> <span style="color: #993333; font-weight: bold;">TABLE_NAME</span><span style="color: #66cc66;">,</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #993333; font-weight: bold;">NULL</span> <span style="color: #993333; font-weight: bold;">AS</span> INDEX_NAME<span style="color: #66cc66;">,</span> <span style="color: #ff0000;">'FULL TEXT'</span> <span style="color: #993333; font-weight: bold;">AS</span> INDEX_TYPE<span style="color: #66cc66;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #ff0000;">'FULLTEXT CATALOG: '</span> <span style="color: #66cc66;">+</span> ftc<span style="color: #66cc66;">.</span>name <span style="color: #993333; font-weight: bold;">AS</span> INDEX_STORAGE<span style="color: #66cc66;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #993333; font-weight: bold;">NULL</span> <span style="color: #993333; font-weight: bold;">AS</span> INDEX_KEY<span style="color: #66cc66;">,</span> &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp;LTRIM<span style="color: #66cc66;">&#40;</span>STUFF<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#40;</span><span style="color: #993333; font-weight: bold;">SELECT</span> N<span style="color: #ff0000;">', '</span> <span style="color: #66cc66;">+</span> c<span style="color: #66cc66;">.</span>name &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #993333; font-weight: bold;">FROM</span> &nbsp; sys<span style="color: #66cc66;">.</span>fulltext_index_columns <span style="color: #993333; font-weight: bold;">AS</span> ftic <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #993333; font-weight: bold;">JOIN</span> sys<span style="color: #66cc66;">.</span><span style="color: #993333; font-weight: bold;">COLUMNS</span> <span style="color: #993333; font-weight: bold;">AS</span> c<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #993333; font-weight: bold;">ON</span> c<span style="color: #66cc66;">.</span>object_id <span style="color: #66cc66;">=</span> ftic<span style="color: #66cc66;">.</span>object_id <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #993333; font-weight: bold;">AND</span> c<span style="color: #66cc66;">.</span>column_id <span style="color: #66cc66;">=</span> ftic<span style="color: #66cc66;">.</span>column_id<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #993333; font-weight: bold;">WHERE</span> &nbsp;ftic<span style="color: #66cc66;">.</span>object_id <span style="color: #66cc66;">=</span> fti<span style="color: #66cc66;">.</span>object_id &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #993333; font-weight: bold;">FOR</span> XML PATH<span style="color: #66cc66;">&#40;</span>N<span style="color: #ff0000;">''</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">,</span> <span style="color: #cc66cc;">1</span><span style="color: #66cc66;">,</span> <span style="color: #cc66cc;">1</span><span style="color: #66cc66;">,</span><span style="color: #ff0000;">''</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">AS</span> INDEX_INCLUDE<span style="color: #66cc66;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #993333; font-weight: bold;">NULL</span> <span style="color: #993333; font-weight: bold;">AS</span> INDEX_FILTER<span style="color: #66cc66;">,</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #ff0000;">'CHANGE_TRACKING = '</span> <span style="color: #66cc66;">+</span> change_tracking_state_desc <span style="color: #66cc66;">+</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #ff0000;">', STOPLIST = '</span> <span style="color: #66cc66;">+</span> <span style="color: #993333; font-weight: bold;">CASE</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #993333; font-weight: bold;">WHEN</span> fti<span style="color: #66cc66;">.</span>stoplist_id <span style="color: #66cc66;">=</span> <span style="color: #cc66cc;">0</span> <span style="color: #993333; font-weight: bold;">THEN</span> <span style="color: #ff0000;">'SYSTEM'</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #993333; font-weight: bold;">WHEN</span> fti<span style="color: #66cc66;">.</span>stoplist_id <span style="color: #993333; font-weight: bold;">IS</span> <span style="color: #993333; font-weight: bold;">NULL</span> <span style="color: #993333; font-weight: bold;">THEN</span> <span style="color: #ff0000;">'OFF'</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #993333; font-weight: bold;">ELSE</span> <span style="color: #66cc66;">&#40;</span><span style="color: #993333; font-weight: bold;">SELECT</span> name <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #993333; font-weight: bold;">FROM</span> &nbsp; sys<span style="color: #66cc66;">.</span>fulltext_stoplists <span style="color: #993333; font-weight: bold;">AS</span> ftsl<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #993333; font-weight: bold;">WHERE</span> &nbsp;fti<span style="color: #66cc66;">.</span>stoplist_id <span style="color: #66cc66;">=</span> ftsl<span style="color: #66cc66;">.</span>stoplist_id<span style="color: #66cc66;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #993333; font-weight: bold;">END</span> <span style="color: #66cc66;">+</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #993333; font-weight: bold;">COALESCE</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">', SEARCH PROPERTY LIST = '</span> <span style="color: #66cc66;">+</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#40;</span><span style="color: #993333; font-weight: bold;">SELECT</span> name <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #993333; font-weight: bold;">FROM</span> &nbsp; sys<span style="color: #66cc66;">.</span>registered_search_property_lists <span style="color: #993333; font-weight: bold;">AS</span> ftpl<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #993333; font-weight: bold;">WHERE</span> &nbsp;fti<span style="color: #66cc66;">.</span>property_list_id <span style="color: #66cc66;">=</span> ftpl<span style="color: #66cc66;">.</span>property_list_id<span style="color: #66cc66;">&#41;</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #993333; font-weight: bold;">COLLATE</span> French_BIN<span style="color: #66cc66;">,</span> <span style="color: #ff0000;">''</span><span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">AS</span> INDEX_WITH <br />
<span style="color: #993333; font-weight: bold;">FROM</span> &nbsp; sys<span style="color: #66cc66;">.</span>fulltext_indexes <span style="color: #993333; font-weight: bold;">AS</span> fti<br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #993333; font-weight: bold;">JOIN</span> sys<span style="color: #66cc66;">.</span>objects <span style="color: #993333; font-weight: bold;">AS</span> o<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #993333; font-weight: bold;">ON</span> fti<span style="color: #66cc66;">.</span>object_id <span style="color: #66cc66;">=</span> o<span style="color: #66cc66;">.</span>object_id<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #993333; font-weight: bold;">JOIN</span> sys<span style="color: #66cc66;">.</span>schemas <span style="color: #993333; font-weight: bold;">AS</span> s &nbsp;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #993333; font-weight: bold;">ON</span> o<span style="color: #66cc66;">.</span>schema_id <span style="color: #66cc66;">=</span> s<span style="color: #66cc66;">.</span>schema_id<br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #993333; font-weight: bold;">JOIN</span> sys<span style="color: #66cc66;">.</span>fulltext_catalogs <span style="color: #993333; font-weight: bold;">AS</span> ftc<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #993333; font-weight: bold;">ON</span> fti<span style="color: #66cc66;">.</span>fulltext_catalog_id <span style="color: #66cc66;">=</span> ftc<span style="color: #66cc66;">.</span>fulltext_catalog_id<br />
<span style="color: #993333; font-weight: bold;">WHERE</span> &nbsp;o<span style="color: #66cc66;">.</span>object_id <span style="color: #66cc66;">=</span> <span style="color: #993333; font-weight: bold;">COALESCE</span><span style="color: #66cc66;">&#40;</span><span style="color: #993333; font-weight: bold;">NULLIF</span><span style="color: #66cc66;">&#40;</span>OBJECT_ID<span style="color: #66cc66;">&#40;</span>@OBJ<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">,</span> <span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">,</span> o<span style="color: #66cc66;">.</span>object_id<span style="color: #66cc66;">&#41;</span><br />
<span style="color: #993333; font-weight: bold;">ORDER</span> &nbsp;<span style="color: #993333; font-weight: bold;">BY</span> <span style="color: #993333; font-weight: bold;">TABLE_NAME</span><span style="color: #66cc66;">,</span> INDEX_KEY<span style="color: #66cc66;">,</span> INDEX_INCLUDE; &nbsp;<br />
<span style="color: #993333; font-weight: bold;">GO</span></div></div>
<p>Il convient de la créer dans la base master et de la rendre procédure système, à l&rsquo;aide de la commande :</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">EXEC sp_MS_marksystemobject 'sp__HELPINDEX';</div></div>
<p><strong>Les colonnes du jeu de données en sortie de procédure sont :</strong></p>
<ul>
<li>TABLE_NAME : nom de la table en deux parties (schéma SQL + nom) </li>
<li>INDEX_NAME : nom de l&rsquo;index. Certains index n&rsquo;ont pas de nom. C&rsquo;est en particulier le cas des index &laquo;&nbsp;fulltext&nbsp;&raquo; </li>
<li>INDEX TYPE : type d&rsquo;index</li>
<li>INDEX_STORAGE : type et nom de l&rsquo;espace de stockage</li>
<li>INDEX_KEY : liste des colonnes composant la clef d&rsquo;index. Certains index n&rsquo;ont pas de clef. C&rsquo;est le cas des index &laquo;&nbsp;columnstore&nbsp;&raquo; et &laquo;&nbsp;fulltext&nbsp;&raquo;. Dans ce cas les colonnes indexées figurent dans la clause INDEX_INCLUDE </li>
<li>INDEX_INCLUDE : liste des colonnes incluses. Pour les index CLUSTERED de type BTree, toutes les colonnes autre que celles de la clef étant présente, la valeur qui y figure est :  * &#8211; (INDEX_KEY). Pour les index CLUSTERED COLUMNSTORE toutes les colonnes de la table étant présente dans l&rsquo;index, la valeur qui y figure est : *</li>
<li>INDEX_FILTER : filtre d&rsquo;index s&rsquo;il y a lieu</li>
<li>INDEX_WITH : principaux paramètres de la clause WITH </li>
</ul>
<p>Si vous l&rsquo;exécutez sans spécifier le nom d&rsquo;une table (le paramètre sera donc NULL) alors la procédure sort la liste des tous les index de toutes les tables, vues indexées comprises.</p>
<p>Vous pouvez transformer aisément cette procédure en une fonction table en ligne avantageuse.</p>
<p><strong>LE CODE * LE CODE * LE CODE * LE CODE * LE CODE * LE CODE * LE CODE * LE CODE * LE CODE</strong><br />
<a href="http://sqlpro.developpez.com/_fichierSQL/sp__helpindex.txt" title="Fichier du code" target="_blank">Le code !</a></p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">Frédéric Brouard, alias SQLpro, ARCHITECTE DE DONNÉES<br />
Expert &nbsp;S.G.B.D &nbsp;relationnelles &nbsp; et &nbsp; langage &nbsp;S.Q.L<br />
Moste &nbsp;Valuable &nbsp;Professionnal &nbsp;Microsoft &nbsp;SQL Server<br />
Société SQLspot &nbsp;: &nbsp;modélisation, conseil, formation,<br />
optimisation, &nbsp;audit, &nbsp;tuning, &nbsp;administration &nbsp;SGBDR<br />
Enseignant: CNAM PACA, ISEN Toulon, CESI Aix en Prov.</div></div>
<p>L&rsquo;entreprise <a href="http://www.sqlspot.com">SQL Spot</a><br />
<strong>Le site web sur le </strong><a href="http://sqlpro.developpez.com/">SQL et les SGBDR</a></p>
<p><img src="http://blog.developpez.com/media/Microsoft_MVP_logo_vertical Brouard 400.jpg" width="400" height="135" alt="MVP Microsoft SQL
Server" /></p>
<div id="attachment_590" style="width: 548px" class="wp-caption alignnone"><a href="http://blog.developpez.com/sqlpro/files/2015/09/Couverture-livre-SQL-server-Eyrolles.jpg"><img src="http://blog.developpez.com/sqlpro/files/2015/09/Couverture-livre-SQL-server-Eyrolles.jpg" alt="Développez et administrez pour la performance avec SQL Server 2014" width="538" height="652" class="size-full wp-image-590" /></a><p class="wp-caption-text">Développez et administrez pour la performance avec SQL Server 2014</p></div>
]]></content:encoded>
			<wfw:commentRss></wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>LIKE &#8216;%mot%&#8217; ou les index rotatifs&#8230;.</title>
		<link>https://blog.developpez.com/sqlpro/p13123/langage-sql-norme/like-mot-ou-les-index-rotatifs</link>
		<comments>https://blog.developpez.com/sqlpro/p13123/langage-sql-norme/like-mot-ou-les-index-rotatifs#comments</comments>
		<pubDate>Thu, 05 Jan 2017 20:01:44 +0000</pubDate>
		<dc:creator><![CDATA[SQLpro]]></dc:creator>
				<category><![CDATA[Langage SQL (norme)]]></category>
		<category><![CDATA[MS SQL Server]]></category>
		<category><![CDATA[SQL Server 2005]]></category>
		<category><![CDATA[SQL Server 2008]]></category>
		<category><![CDATA[SQL Server 2012]]></category>
		<category><![CDATA[SQL Server 2014]]></category>
		<category><![CDATA[SQL Server 2016]]></category>
		<category><![CDATA[index]]></category>
		<category><![CDATA[joker]]></category>
		<category><![CDATA[LIKE]]></category>
		<category><![CDATA[recherche]]></category>
		<category><![CDATA[sql]]></category>

		<guid isPermaLink="false">http://blog.developpez.com/sqlpro/?p=687</guid>
		<description><![CDATA[Qui n&#8217;a jamais rêvé d&#8217;obtenir des performances pour rechercher des mots partiels contenus dans d&#8217;autres mots, comme par exemple tous les mots contenant &#171;&#160;bolo&#160;&#187; ? Dans un dictionnaire de 128 918 mots, une telle recherche met moins de 50 millisecondes à l&#8217;aide des index rotatifs, contre ??? pour le LIKE &#8216;%bolo%&#8217;&#8230; Explications&#8230; diabolos, hyperboloïde, bolonaise, [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>Qui n&rsquo;a jamais rêvé d&rsquo;obtenir des performances pour rechercher des mots partiels contenus dans d&rsquo;autres mots, comme par exemple tous les mots contenant &laquo;&nbsp;bolo&nbsp;&raquo; ? Dans un dictionnaire de 128 918 mots, une telle recherche met moins de 50 millisecondes à l&rsquo;aide des index rotatifs, contre ??? pour le LIKE &lsquo;%bolo%&rsquo;&#8230; Explications&#8230;<br />
<span id="more-687"></span><br />
diabolos, hyperboloïde, bolonaise, bolomètre, diabolo, bolométriques, amphibologie, bolonais, paraboloïde, amphibologique, bolométrique&#8230; Tels sont les mots du dictionnaire LEXIQUE du CNRS contenant la chaine de caractères &laquo;&nbsp;boblo&nbsp;&raquo;.</p>
<p><strong>LE PROBLÈME</strong></p>
<p>Les index des bases de données relationnelles, de type BTree (arbre équilibrés) trient les chaines de caractères par rapport à l&rsquo;ordre orthographique des chaines de caractères au regard du classement des lettres de l&rsquo;alphabet et de la collation choisie, cette dernière pouvant être sensible ou non, à la casse, aux accents&#8230;. Du fait de cet ordre, il est donc possible de rechercher par intervalle comme c&rsquo;est le cas de la recherche d&rsquo;un mot commençant par&#8230; En effet, si nous recherchons les mots commençant par &laquo;&nbsp;fass&nbsp;&raquo; ils sont regroupés les uns à la suite des autres dans l&rsquo;index, ce qui permet un accès immédiat et la solution est, par exemple la suivante :
<ol>
<ul>fasse</ul>
<ul>fassent</ul>
<ul>fasses</ul>
<ul>fassiez</ul>
<ul>fassions</ul>
</ol>
<p>Pour ce qui est des mots finissant par, l&rsquo;index ne nous est d&rsquo;aucune utilité, mais une astuce consiste à créer les mots inversés (par exemple à l&rsquo;aide d&rsquo;une colonne calculée), les indexer et rechercher par le même type de LIKE sur l&rsquo;inverse de la terminaison souhaitée. Par exemple, rechercher tous les mots se terminant par &laquo;&nbsp;aide&rsquo;, il suffit de faire la recherche suivante :</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;">LIKE</span> <span style="color: #ff0000;">'edia%'</span></div></div>
<p>et de renvoyer le mot correspondant !<br />
Bien entendu pour rechercher un mot commençant par&#8230; et finissant par&#8230;, il suffit de combiner les deux recherches !<br />
Un exemple est apporté par l&rsquo;extrait de requête suivant :</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;">WHERE</span> MOT_MOT <span style="color: #993333; font-weight: bold;">LIKE</span> <span style="color: #ff0000;">'enta%'</span> <span style="color: #993333; font-weight: bold;">AND</span> MOT_INVERSE <span style="color: #993333; font-weight: bold;">LIKE</span> CONCAT<span style="color: #66cc66;">&#40;</span>REVERSE<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'aient'</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">,</span> <span style="color: #ff0000;">'%'</span><span style="color: #66cc66;">&#41;</span></div></div>
<p>Mais comment être efficace lorsque l&rsquo;on recherche une chaine à l&rsquo;intérieur d&rsquo;un mot ? C&rsquo;est là qu&rsquo;intervient la notion d&rsquo;index &laquo;&nbsp;rotatif&nbsp;&raquo;&#8230;</p>
<p><strong>LE CONCEPT</strong></p>
<p><strong>Un index &laquo;&nbsp;rotatif&nbsp;&raquo;</strong> est en fait une liste de mots pour laquelle on supprime successivement la lettre du début à chaque tour, d&rsquo;où le nom d&rsquo;index &laquo;&nbsp;rotatif&nbsp;&raquo;.<br />
Par exemple le mot &laquo;&nbsp;locomotive&nbsp;&raquo; sera ainsi décliné :
<ol>
<ul>locomotive</ul>
<ul>ocomotive</ul>
<ul>comotive</ul>
<ul>omotive</ul>
<ul>motive</ul>
<ul>otive</ul>
<ul>tive</ul>
<ul>ive</ul>
<ul>ve</ul>
<ul>e</ul>
</ol>
<p>On numérote alors chaque rotation, y compris le mot racine dont par convention on attribuera l&rsquo;indice 0 comme niveau de rotation. Par exemple le &laquo;&nbsp;sous-mot&nbsp;&raquo; &laquo;&nbsp;motive&nbsp;&raquo; aura un indice de rotation de 4 parce qu&rsquo;on lui aura retiré les 4 premières lettres.<br />
Une fois ces mots Ajoutés dans une table de mots, il suffit de les indexer et d&rsquo;ajouter une table des références croisées entre les mots racine et les rotations. La recherche peut désormais se faire via un LIKE &lsquo;mot%&rsquo; qui permet d&rsquo;exploiter l&rsquo;index ! Mais il faut ensuite remonter au mot racine par une jointure à l&rsquo;aide de la table des références croisées.</p>
<p><strong>LA MÉCANIQUE</strong></p>
<p>Afin de bien distinguer ces objets techniques de votre base, objets qui n&rsquo;ont rien à voir avec les objets fonctionnels de votre application, je vous conseille de créer un schéma SQL spécifique pour les y stocker logiquement</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> SCHEMA S_XRT;</div></div>
<p><strong>Les tables pour ce faire.</strong></p>
<p>Deux tables suffisent : la table des mots, et la table des références croisées.</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;">TABLE</span> S_XRT<span style="color: #66cc66;">.</span>T_MOT<br />
<span style="color: #66cc66;">&#40;</span>MOT_ID &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #993333; font-weight: bold;">INT</span> <span style="color: #993333; font-weight: bold;">IDENTITY</span> <span style="color: #993333; font-weight: bold;">PRIMARY</span> <span style="color: #993333; font-weight: bold;">KEY</span><span style="color: #66cc66;">,</span><br />
<span style="color: #808080; font-style: italic;">--&gt; doit être sensible aux accents mais pas à la casse ! Exemple maïs et </span><br />
<span style="color: #808080; font-style: italic;">-- &nbsp;mais, sur et sûr, retraite et retraité, congres et congrès !</span><br />
&nbsp;MOT_MOT &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #993333; font-weight: bold;">VARCHAR</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">32</span><span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">COLLATE</span> French_BIN <span style="color: #993333; font-weight: bold;">NOT</span> <span style="color: #993333; font-weight: bold;">NULL</span> <span style="color: #993333; font-weight: bold;">UNIQUE</span><span style="color: #66cc66;">&#41;</span>;</div></div>
<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;">TABLE</span> S_XRT<span style="color: #66cc66;">.</span>T_MOT_ROTATION_MRT<br />
<span style="color: #66cc66;">&#40;</span>MRT_ID &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #993333; font-weight: bold;">INT</span> <span style="color: #993333; font-weight: bold;">IDENTITY</span> <span style="color: #993333; font-weight: bold;">PRIMARY</span> <span style="color: #993333; font-weight: bold;">KEY</span><span style="color: #66cc66;">,</span><br />
<span style="color: #808080; font-style: italic;">-- pointe vers la rotation du mot</span><br />
&nbsp;MOT_ID &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #993333; font-weight: bold;">INT</span> <span style="color: #993333; font-weight: bold;">NOT</span> <span style="color: #993333; font-weight: bold;">NULL</span> <span style="color: #993333; font-weight: bold;">REFERENCES</span> S_XRT<span style="color: #66cc66;">.</span>T_MOT <span style="color: #66cc66;">&#40;</span>MOT_ID<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">,</span><br />
<span style="color: #808080; font-style: italic;">-- pointe vers la racine du mot</span><br />
&nbsp;MOT_ID_RACINE &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #993333; font-weight: bold;">INT</span> <span style="color: #993333; font-weight: bold;">NOT</span> <span style="color: #993333; font-weight: bold;">NULL</span> <span style="color: #993333; font-weight: bold;">REFERENCES</span> S_XRT<span style="color: #66cc66;">.</span>T_MOT <span style="color: #66cc66;">&#40;</span>MOT_ID<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">,</span><br />
<span style="color: #808080; font-style: italic;">-- indice de rotation</span><br />
&nbsp;MRT_ROTATION &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;TINYINT <span style="color: #993333; font-weight: bold;">NOT</span> <span style="color: #993333; font-weight: bold;">NULL</span><span style="color: #66cc66;">,</span><br />
&nbsp;<span style="color: #993333; font-weight: bold;">UNIQUE</span> <span style="color: #66cc66;">&#40;</span>MOT_ID<span style="color: #66cc66;">,</span> MOT_ID_RACINE<span style="color: #66cc66;">,</span> MRT_ROTATION<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;</div></div>
<p><strong>Les routines</strong></p>
<p>Une procédure va permettre d&rsquo;indexer un mot. En voici le code en Transact SQL :</p>
<div class="codecolorer-container sql default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:300px;"><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;">PROCEDURE</span> S_XRT<span style="color: #66cc66;">.</span>P_INDEXATION_ROTATIVE @MOT <span style="color: #993333; font-weight: bold;">VARCHAR</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">32</span><span style="color: #66cc66;">&#41;</span><br />
<span style="color: #993333; font-weight: bold;">AS</span><br />
<br />
<span style="color: #993333; font-weight: bold;">SET</span> NOCOUNT <span style="color: #993333; font-weight: bold;">ON</span>;<br />
<br />
<span style="color: #993333; font-weight: bold;">SET</span> @MOT <span style="color: #66cc66;">=</span> <span style="color: #993333; font-weight: bold;">LOWER</span><span style="color: #66cc66;">&#40;</span>LTRIM<span style="color: #66cc66;">&#40;</span>RTRIM<span style="color: #66cc66;">&#40;</span>@MOT<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;<br />
<br />
<span style="color: #993333; font-weight: bold;">DECLARE</span> @L TINYINT <span style="color: #66cc66;">=</span> LEN<span style="color: #66cc66;">&#40;</span>@MOT<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">,</span> @ID_MOT <span style="color: #993333; font-weight: bold;">INT</span>;<br />
<br />
<span style="color: #993333; font-weight: bold;">DECLARE</span> @ROTATIONS <span style="color: #993333; font-weight: bold;">TABLE</span> <br />
<span style="color: #66cc66;">&#40;</span>MOT &nbsp; <span style="color: #993333; font-weight: bold;">VARCHAR</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">32</span><span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">COLLATE</span> French_BIN<span style="color: #66cc66;">,</span><br />
&nbsp;ROT &nbsp; TINYINT<span style="color: #66cc66;">&#41;</span>;<br />
<br />
<span style="color: #808080; font-style: italic;">-- calcul des rotations, racine comprise (0)</span><br />
<span style="color: #993333; font-weight: bold;">WITH</span> T <span style="color: #993333; font-weight: bold;">AS</span> <br />
<span style="color: #66cc66;">&#40;</span><span style="color: #993333; font-weight: bold;">SELECT</span> @MOT <span style="color: #993333; font-weight: bold;">AS</span> M<span style="color: #66cc66;">,</span> <span style="color: #cc66cc;">0</span> <span style="color: #993333; font-weight: bold;">AS</span> I<br />
&nbsp;<span style="color: #993333; font-weight: bold;">UNION</span> &nbsp;<span style="color: #993333; font-weight: bold;">ALL</span><br />
&nbsp;<span style="color: #993333; font-weight: bold;">SELECT</span> <span style="color: #993333; font-weight: bold;">RIGHT</span><span style="color: #66cc66;">&#40;</span>M<span style="color: #66cc66;">,</span> @L<span style="color: #66cc66;">-</span>I <span style="color: #66cc66;">-</span> <span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">,</span> I <span style="color: #66cc66;">+</span> <span style="color: #cc66cc;">1</span><br />
&nbsp;<span style="color: #993333; font-weight: bold;">FROM</span> &nbsp; T<br />
&nbsp;<span style="color: #993333; font-weight: bold;">WHERE</span> &nbsp;I <span style="color: #66cc66;">&lt;</span> @L <span style="color: #66cc66;">-</span> <span style="color: #cc66cc;">1</span><br />
<span style="color: #66cc66;">&#41;</span><br />
<span style="color: #993333; font-weight: bold;">INSERT</span> <span style="color: #993333; font-weight: bold;">INTO</span> @ROTATIONS<br />
<span style="color: #993333; font-weight: bold;">SELECT</span> <span style="color: #66cc66;">*</span> <span style="color: #993333; font-weight: bold;">FROM</span> T;<br />
<br />
<span style="color: #808080; font-style: italic;">-- insertions des mots manquants</span><br />
<span style="color: #993333; font-weight: bold;">INSERT</span> <span style="color: #993333; font-weight: bold;">INTO</span> S_XRT<span style="color: #66cc66;">.</span>T_MOT<br />
<span style="color: #993333; font-weight: bold;">SELECT</span> MOT<br />
<span style="color: #993333; font-weight: bold;">FROM</span> &nbsp; @ROTATIONS<br />
<span style="color: #993333; font-weight: bold;">WHERE</span> &nbsp;MOT <span style="color: #993333; font-weight: bold;">NOT</span> <span style="color: #993333; font-weight: bold;">IN</span> <span style="color: #66cc66;">&#40;</span><span style="color: #993333; font-weight: bold;">SELECT</span> MOT_MOT<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #993333; font-weight: bold;">FROM</span> &nbsp; S_XRT<span style="color: #66cc66;">.</span>T_MOT<span style="color: #66cc66;">&#41;</span>;<br />
<br />
<span style="color: #808080; font-style: italic;">-- récupération de l'ID du mot racine</span><br />
<span style="color: #993333; font-weight: bold;">SELECT</span> @ID_MOT <span style="color: #66cc66;">=</span> MOT_ID<br />
<span style="color: #993333; font-weight: bold;">FROM</span> &nbsp; S_XRT<span style="color: #66cc66;">.</span>T_MOT<br />
<span style="color: #993333; font-weight: bold;">WHERE</span> &nbsp;MOT_MOT <span style="color: #66cc66;">=</span> @MOT;<br />
<br />
<span style="color: #808080; font-style: italic;">-- insertions des rotations manquantes</span><br />
<span style="color: #993333; font-weight: bold;">INSERT</span> <span style="color: #993333; font-weight: bold;">INTO</span> S_XRT<span style="color: #66cc66;">.</span>T_MOT_ROTATION_MRT<br />
<span style="color: #993333; font-weight: bold;">SELECT</span> M<span style="color: #66cc66;">.</span>MOT_ID<span style="color: #66cc66;">,</span> @ID_MOT<span style="color: #66cc66;">,</span> R<span style="color: #66cc66;">.</span>ROT<br />
<span style="color: #993333; font-weight: bold;">FROM</span> &nbsp; @ROTATIONS <span style="color: #993333; font-weight: bold;">AS</span> R<br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #993333; font-weight: bold;">JOIN</span> S_XRT<span style="color: #66cc66;">.</span>T_MOT <span style="color: #993333; font-weight: bold;">AS</span> M<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #993333; font-weight: bold;">ON</span> R<span style="color: #66cc66;">.</span>MOT <span style="color: #66cc66;">=</span> M<span style="color: #66cc66;">.</span>MOT_MOT<br />
<span style="color: #993333; font-weight: bold;">WHERE</span> &nbsp;<span style="color: #993333; font-weight: bold;">NOT</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 />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #993333; font-weight: bold;">FROM</span> &nbsp; S_XRT<span style="color: #66cc66;">.</span>T_MOT_ROTATION_MRT <span style="color: #993333; font-weight: bold;">AS</span> MR<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #993333; font-weight: bold;">WHERE</span> &nbsp;MR<span style="color: #66cc66;">.</span>MOT_ID <span style="color: #66cc66;">=</span> M<span style="color: #66cc66;">.</span>MOT_ID<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #993333; font-weight: bold;">AND</span> &nbsp;MR<span style="color: #66cc66;">.</span>MOT_ID_RACINE <span style="color: #66cc66;">=</span> @ID_MOT<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #993333; font-weight: bold;">AND</span> &nbsp;MR<span style="color: #66cc66;">.</span>MRT_ROTATION <span style="color: #66cc66;">=</span> R<span style="color: #66cc66;">.</span>ROT<span style="color: #66cc66;">&#41;</span>;</div></div>
<p>Enfin, une fonction table constituée d&rsquo;une simple requête paramétrée, va permettre de retrouver les mots racine à partir des partiels :</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;">FUNCTION</span> S_XRT<span style="color: #66cc66;">.</span>F_SUPER_LIKE <span style="color: #66cc66;">&#40;</span>@MOT <span style="color: #993333; font-weight: bold;">VARCHAR</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">32</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><br />
<span style="color: #993333; font-weight: bold;">RETURNS</span> <span style="color: #993333; font-weight: bold;">TABLE</span><br />
<span style="color: #993333; font-weight: bold;">AS</span><br />
<span style="color: #993333; font-weight: bold;">RETURN</span> <span style="color: #66cc66;">&#40;</span><span style="color: #993333; font-weight: bold;">SELECT</span> MR<span style="color: #66cc66;">.</span>MOT_ID<span style="color: #66cc66;">,</span> MR<span style="color: #66cc66;">.</span>MOT_MOT<br />
<span style="color: #993333; font-weight: bold;">FROM</span> &nbsp; S_XRT<span style="color: #66cc66;">.</span>T_MOT <span style="color: #993333; font-weight: bold;">AS</span> M<br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #993333; font-weight: bold;">JOIN</span> <span style="color: #66cc66;">&#91;</span>S_XRT<span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">.</span><span style="color: #66cc66;">&#91;</span>T_MOT_ROTATION_MRT<span style="color: #66cc66;">&#93;</span> <span style="color: #993333; font-weight: bold;">AS</span> R<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #993333; font-weight: bold;">ON</span> M<span style="color: #66cc66;">.</span>MOT_ID <span style="color: #66cc66;">=</span> R<span style="color: #66cc66;">.</span>MOT_ID<br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #993333; font-weight: bold;">JOIN</span> S_XRT<span style="color: #66cc66;">.</span>T_MOT <span style="color: #993333; font-weight: bold;">AS</span> MR<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #993333; font-weight: bold;">ON</span> R<span style="color: #66cc66;">.</span>MOT_ID_RACINE <span style="color: #66cc66;">=</span> MR<span style="color: #66cc66;">.</span>MOT_ID<br />
<span style="color: #993333; font-weight: bold;">WHERE</span> &nbsp;M<span style="color: #66cc66;">.</span>MOT_MOT <span style="color: #993333; font-weight: bold;">LIKE</span> <span style="color: #993333; font-weight: bold;">LOWER</span><span style="color: #66cc66;">&#40;</span>RTRIM<span style="color: #66cc66;">&#40;</span>LTRIM<span style="color: #66cc66;">&#40;</span>@MOT<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">+</span> <span style="color: #ff0000;">'%'</span><span style="color: #66cc66;">&#41;</span>;</div></div>
<p><strong>QUELQUES TESTS</strong></p>
<p>Nous sommes partis d&rsquo;une base contenant le dictionnaire LEXIQUE du CNRS, comportant 128 918 mots.<br />
Notre méthode pour les indexer tous a été d&rsquo;utiliser un curseur pour connaitre le temps moyen mis par la procédure d&rsquo;indexation. Ce traitement a été effectué sur une machine ayant les caractéristiques suivantes : 2 processeurs XEON, 48 cœurs , 128 Go de RAM, 8 disques SAS en RAID 10 avec SQL Server 2016.<br />
Le temps de traitement a été de 26 minutes et 21 secondes, soit, pour 128 918 mots, 12 ms par mot.<br />
Le traitement a généré  :<br />
*   376 567 entrées de mots dans la table S_XRT.T_MOT (représentant 24 Mo)<br />
* 1 168 547 lignes dans la table S_XRT.T_MOT_ROTATION_MRT (représentant 62 Mo)<br />
À noter qu&rsquo;après réindexation, on observe une diminution du volume des données : 22 et 57 Ko respectivement.</p>
<p>Voici le batch que nous avons utilisé (la table du dictionnaire LEXIQUE du CNRS est dbo.TS_MOT_MOT :</p>
<div class="codecolorer-container sql default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:300px;"><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;">DECLARE</span> @T DATETIME <span style="color: #66cc66;">=</span> GETDATE<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;<br />
<br />
<span style="color: #993333; font-weight: bold;">DECLARE</span> C CURSOR <br />
&nbsp; &nbsp;<span style="color: #993333; font-weight: bold;">LOCAL</span> FORWARD_ONLY STATIC READ_ONLY<br />
<span style="color: #993333; font-weight: bold;">FOR</span> <br />
&nbsp; &nbsp;<span style="color: #993333; font-weight: bold;">SELECT</span> MOT_MOT <br />
&nbsp; &nbsp;<span style="color: #993333; font-weight: bold;">FROM</span> &nbsp; dbo<span style="color: #66cc66;">.</span>TS_MOT_MOT<br />
&nbsp; &nbsp;<span style="color: #993333; font-weight: bold;">WHERE</span> &nbsp;MOT_LONGUEUR <span style="color: #66cc66;">&gt;</span> <span style="color: #cc66cc;">1</span>;<br />
<br />
<span style="color: #993333; font-weight: bold;">DECLARE</span> @MOT <span style="color: #993333; font-weight: bold;">VARCHAR</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">32</span><span style="color: #66cc66;">&#41;</span>;<br />
<br />
<span style="color: #993333; font-weight: bold;">OPEN</span> C;<br />
<br />
FETCH C <span style="color: #993333; font-weight: bold;">INTO</span> @MOT;<br />
<br />
WHILE @@FETCH_STATUS <span style="color: #66cc66;">=</span> <span style="color: #cc66cc;">0</span><br />
<span style="color: #993333; font-weight: bold;">BEGIN</span><br />
<br />
&nbsp; &nbsp;<span style="color: #993333; font-weight: bold;">EXEC</span> S_XRT<span style="color: #66cc66;">.</span>P_INDEXATION_ROTATIVE @MOT;<br />
&nbsp; &nbsp;FETCH C <span style="color: #993333; font-weight: bold;">INTO</span> @MOT;<br />
<br />
<span style="color: #993333; font-weight: bold;">END</span>;<br />
<br />
CLOSE C;<br />
<br />
DEALLOCATE C;<br />
<br />
<span style="color: #993333; font-weight: bold;">SELECT</span> DATEDIFF<span style="color: #66cc66;">&#40;</span>ms<span style="color: #66cc66;">,</span> @T<span style="color: #66cc66;">,</span> GETDATE<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;</div></div>
<p>L&rsquo;utilisation de la fonction table en ligne S_XRT.F_SUPER_LIKE, met en moyenne 50 ms quelques soit la racine cherchée si elle est constituée d&rsquo;au moins 3 caractères. Exemple :</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> S_XRT<span style="color: #66cc66;">.</span>F_SUPER_LIKE<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'moti'</span><span style="color: #66cc66;">&#41;</span>;</div></div>
<p>Pour la pire des recherches, le système met moins d&rsquo;une seconde à trouver les 130 162 mots contenant la lettre e !</p>
<p>Pour comparaison, la recherche des mots comprenant les caractères &laquo;&nbsp;eta&nbsp;&raquo;, d&rsquo;une part directement dans le dictionnaire à l&rsquo;aide d&rsquo;un LIKE &lsquo;%eta%&rsquo; et d&rsquo;autres part dans l&rsquo;index rotatif donne les métriques suivantes :<br />
* Dictionnaire, LIKE&rsquo;%eta%&rsquo; : temps UC = 652 ms, temps écoulé = 430 ms.<br />
* Index rotatif, S_XRT.F_SUPER_LIKE (&lsquo;eta&rsquo;) : Temps UC = 265 ms, temps écoulé = 50 ms.</p>
<p>Paradoxalement les plans de requête ne reflètent pas vraiment cette différence. les couts des plans apparaissent ainsi :<br />
* Index rotatif, S_XRT.F_SUPER_LIKE (&lsquo;eta&rsquo;) : 3,79 (soit 86 % de l&rsquo;ensemble<br />
* Dictionnaire, LIKE&rsquo;%eta%&rsquo; : 0,61 (soit 14% de l&rsquo;ensemble)</p>
<div id="attachment_692" style="width: 635px" class="wp-caption alignnone"><a href="http://blog.developpez.com/sqlpro/files/2017/01/Fonction-SUPER-LIKE.jpg"><img src="http://blog.developpez.com/sqlpro/files/2017/01/Fonction-SUPER-LIKE-1024x132.jpg" alt="Plan de requête SQL Server utilisant une fonction table en ligne et l&#039;index rotatif" width="800" height="104" class="size-large wp-image-692" /></a><p class="wp-caption-text">Plan de requête SQL Server utilisant une fonction table en ligne et l&rsquo;index rotatif</p></div>
<div id="attachment_693" style="width: 223px" class="wp-caption alignnone"><a href="http://blog.developpez.com/sqlpro/files/2017/01/LIKE-direct.jpg"><img src="http://blog.developpez.com/sqlpro/files/2017/01/LIKE-direct.jpg" alt="Utilisation directe du LIKE &#039;%toto%&#039;" width="213" height="68" class="size-full wp-image-693" /></a><p class="wp-caption-text">Utilisation directe du LIKE &lsquo;%toto%&rsquo;</p></div>
<p><strong>UN PEU D&rsquo;ASTUCE</strong></p>
<p>Au fur et à mesure de son utilisation, les index rotatifs grandissent de moins en moins, car ils contiennent déjà des rotations utilisables pour d&rsquo;autres mots. On peut donc prévoir certaines manœuvres pour les rendre plus efficaces encore, comme le précalcul de certaines données, la compression des index ou encore l&rsquo;utilisation de vues matérialisées (ou indexées sur SQL Server).</p>
<p>À titre d&rsquo;exemple, nous avons obtenus la métrique suivante : temps UC = 63 ms, temps écoulé = 67 ms, à  l&rsquo;aide de l&rsquo;une de ces techniques !</p>
<p><strong>LE CODE * LE CODE * LE CODE * LE CODE * LE CODE * LE CODE * LE CODE * LE CODE * LE CODE</strong><br />
<a href="http://sqlpro.developpez.com/_fichierSQL/IndexRotatifs.txt" title="Fichier du code" target="_blank">Le code SQL</a></p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">Frédéric Brouard, alias SQLpro, ARCHITECTE DE DONNÉES<br />
Expert &nbsp;S.G.B.D &nbsp;relationnelles &nbsp; et &nbsp; langage &nbsp;S.Q.L<br />
Moste &nbsp;Valuable &nbsp;Professionnal &nbsp;Microsoft &nbsp;SQL Server<br />
Société SQLspot &nbsp;: &nbsp;modélisation, conseil, formation,<br />
optimisation, &nbsp;audit, &nbsp;tuning, &nbsp;administration &nbsp;SGBDR<br />
Enseignant: CNAM PACA, ISEN Toulon, CESI Aix en Prov.</div></div>
<p>L&rsquo;entreprise <a href="http://www.sqlspot.com">SQL Spot</a><br />
<strong>Le site web sur le </strong><a href="http://sqlpro.developpez.com/">SQL et les SGBDR</a></p>
<p><img src="http://blog.developpez.com/media/Microsoft_MVP_logo_vertical Brouard 400.jpg" width="400" height="135" alt="MVP Microsoft SQL
Server" /></p>
<div id="attachment_590" style="width: 548px" class="wp-caption alignnone"><a href="http://blog.developpez.com/sqlpro/files/2015/09/Couverture-livre-SQL-server-Eyrolles.jpg"><img src="http://blog.developpez.com/sqlpro/files/2015/09/Couverture-livre-SQL-server-Eyrolles.jpg" alt="Développez et administrez pour la performance avec SQL Server 2014" width="538" height="652" class="size-full wp-image-590" /></a><p class="wp-caption-text">Développez et administrez pour la performance avec SQL Server 2014</p></div>
]]></content:encoded>
			<wfw:commentRss></wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>SQL Server 2014 &#8211; les ressources du livre</title>
		<link>https://blog.developpez.com/sqlpro/p13035/ms-sql-server/sql-server-2014-les-ressources-du-livre</link>
		<comments>https://blog.developpez.com/sqlpro/p13035/ms-sql-server/sql-server-2014-les-ressources-du-livre#comments</comments>
		<pubDate>Wed, 04 May 2016 12:44:42 +0000</pubDate>
		<dc:creator><![CDATA[SQLpro]]></dc:creator>
				<category><![CDATA[MS SQL Server]]></category>
		<category><![CDATA[SQL Server 2005]]></category>
		<category><![CDATA[SQL Server 2008]]></category>
		<category><![CDATA[SQL Server 2012]]></category>
		<category><![CDATA[SQL Server 2014]]></category>
		<category><![CDATA[SQL Server 2016]]></category>
		<category><![CDATA[glossaire]]></category>
		<category><![CDATA[index]]></category>
		<category><![CDATA[livre]]></category>
		<category><![CDATA[SQL server]]></category>
		<category><![CDATA[table des matières]]></category>

		<guid isPermaLink="false">http://blog.developpez.com/sqlpro/?p=670</guid>
		<description><![CDATA[Notre livre publié aux éditions Eyrolles en 2014 possède plusieurs ajouts dont les ressources peuvent être téléchargées&#8230; Pour la partie 5 du livre, vous la trouverez à l&#8217;URL : http://www.st1.eyrolles.com/9782212135923/Annexes_Brouard_FILIGRANE.pdf Pour les exemples, vous trouverez un fichier ZIP à l&#8217;URL : http://www.eyrolles.com/download/9782212135923/Scripts_SQL_2014.zip La table des matières est disponible ici : Table des matières SQL Server [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>Notre livre publié aux éditions Eyrolles en 2014 possède plusieurs ajouts dont les ressources peuvent être téléchargées&#8230;<br />
<span id="more-670"></span><br />
Pour la<strong> partie 5</strong> du livre, vous la trouverez à l&rsquo;URL :<br />
<a href="http://www.st1.eyrolles.com/9782212135923/Annexes_Brouard_FILIGRANE.pdf" title="Partie 5 livre SQL Server 2014 Eyrolles" target="_blank">http://www.st1.eyrolles.com/9782212135923/Annexes_Brouard_FILIGRANE.pdf</a></p>
<p>Pour les <strong>exemples</strong>, vous trouverez un fichier ZIP à l&rsquo;URL :<br />
<a href="http://www.eyrolles.com/download/9782212135923/Scripts_SQL_2014.zip" title="Exemples du livre SQL Server 2014 Eyrolles" target="_blank">http://www.eyrolles.com/download/9782212135923/Scripts_SQL_2014.zip</a></p>
<p><strong>La table des matières est disponible ici :</strong><br />
<a href="http://blog.developpez.com/sqlpro/files/2016/05/Table-des-matières-SQL-Server-2014.pdf">Table des matières SQL Server 2014</a></p>
<p><strong>L&rsquo;index est disponible ici :</strong><br />
<a href="http://blog.developpez.com/sqlpro/files/2016/05/Index-SQL-Server-2014.pdf">Index SQL Server 2014</a></p>
<p><strong>Le glossaire est disponible ici :</strong><br />
<a href="http://blog.developpez.com/sqlpro/files/2016/05/Glossaire-SQL-Server-2014.pdf">Glossaire SQL Server 2014</a></p>
<div id="attachment_590" style="width: 548px" class="wp-caption alignnone"><a href="http://blog.developpez.com/sqlpro/files/2015/09/Couverture-livre-SQL-server-Eyrolles.jpg"><img src="http://blog.developpez.com/sqlpro/files/2015/09/Couverture-livre-SQL-server-Eyrolles.jpg" alt="Développez et administrez pour la performance avec SQL Server 2014" width="538" height="652" class="size-full wp-image-590" /></a><p class="wp-caption-text">Développez et administrez pour la performance avec SQL Server 2014</p></div>
<p>***</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">Frédéric Brouard, alias SQLpro, ARCHITECTE DE DONNÉES<br />
Expert &nbsp;S.G.B.D &nbsp;relationnelles &nbsp; et &nbsp; langage &nbsp;S.Q.L<br />
Moste &nbsp;Valuable &nbsp;Professionnal &nbsp;Microsoft &nbsp;SQL Server<br />
Société SQLspot &nbsp;: &nbsp;modélisation, conseil, formation,<br />
optimisation, &nbsp;audit, &nbsp;tuning, &nbsp;administration &nbsp;SGBDR<br />
Enseignant: CNAM PACA, ISEN Toulon, CESI Aix en Prov.</div></div>
<p>L&rsquo;entreprise <a href="http://www.sqlspot.com">SQL Spot</a><br />
<strong>Le site web sur le </strong><a href="http://sqlpro.developpez.com/">SQL et les SGBDR</a></p>
<p><img src="http://blog.developpez.com/media/Microsoft_MVP_logo_vertical Brouard 400.jpg" width="400" height="135" alt="MVP Microsoft SQL
Server" /></p>
]]></content:encoded>
			<wfw:commentRss></wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Détecter les index obèses</title>
		<link>https://blog.developpez.com/sqlpro/p12964/ms-sql-server/detecter-les-index-obeses</link>
		<comments>https://blog.developpez.com/sqlpro/p12964/ms-sql-server/detecter-les-index-obeses#comments</comments>
		<pubDate>Wed, 09 Dec 2015 09:59:02 +0000</pubDate>
		<dc:creator><![CDATA[SQLpro]]></dc:creator>
				<category><![CDATA[MS SQL Server]]></category>
		<category><![CDATA[SQL Server 2005]]></category>
		<category><![CDATA[SQL Server 2008]]></category>
		<category><![CDATA[SQL Server 2012]]></category>
		<category><![CDATA[SQL Server 2014]]></category>
		<category><![CDATA[SQL Server 2016]]></category>
		<category><![CDATA[clé]]></category>
		<category><![CDATA[clef]]></category>
		<category><![CDATA[index]]></category>
		<category><![CDATA[obèse]]></category>
		<category><![CDATA[performance]]></category>
		<category><![CDATA[SQL server]]></category>

		<guid isPermaLink="false">http://blog.developpez.com/sqlpro/?p=641</guid>
		<description><![CDATA[Voici en complément des 20 requêtes pour auditer la qualité de votre modèle de données (voir 20 requêtes pour auditer la qualité de votre modèle de données) une requête destinée à déceler les index obèses (c&#8217;est à dire, ceux ayant trop de colonnes dans leur définition. Voici la requête : WITH T0 AS &#40; SELECT [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>Voici en complément des 20 requêtes pour auditer la qualité de votre modèle de données (voir <a href="http://blog.developpez.com/sqlpro/p12963/ms-sql-server/20-requetes-pour-auditer-la-qualite-de-la-structure-de-votre-base-de-donnees">20 requêtes pour auditer la qualité de votre modèle de données</a>) une requête destinée à déceler les index obèses (c&rsquo;est à dire, ceux ayant trop de colonnes dans leur définition.<br />
<span id="more-641"></span><br />
<strong>Voici la requête : </strong></p>
<div class="codecolorer-container sql default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:300px;"><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;">WITH</span> <br />
T0 <span style="color: #993333; font-weight: bold;">AS</span> <br />
<span style="color: #66cc66;">&#40;</span><br />
<span style="color: #993333; font-weight: bold;">SELECT</span> o<span style="color: #66cc66;">.</span>object_id<span style="color: #66cc66;">,</span> i<span style="color: #66cc66;">.</span>index_id<span style="color: #66cc66;">,</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp;s<span style="color: #66cc66;">.</span>name <span style="color: #993333; font-weight: bold;">AS</span> TABLE_SCHEMA<span style="color: #66cc66;">,</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp;o<span style="color: #66cc66;">.</span>name <span style="color: #993333; font-weight: bold;">AS</span> <span style="color: #993333; font-weight: bold;">TABLE_NAME</span><span style="color: #66cc66;">,</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp;i<span style="color: #66cc66;">.</span>name <span style="color: #993333; font-weight: bold;">AS</span> INDEX_NAME<span style="color: #66cc66;">,</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp;is_included_column<span style="color: #66cc66;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #993333; font-weight: bold;">COUNT</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">*</span><span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">AS</span> NOMBRE<br />
<span style="color: #993333; font-weight: bold;">FROM</span> &nbsp; sys<span style="color: #66cc66;">.</span>objects <span style="color: #993333; font-weight: bold;">AS</span> o<br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #993333; font-weight: bold;">JOIN</span> sys<span style="color: #66cc66;">.</span>schemas <span style="color: #993333; font-weight: bold;">AS</span> s<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #993333; font-weight: bold;">ON</span> o<span style="color: #66cc66;">.</span>schema_id <span style="color: #66cc66;">=</span> s<span style="color: #66cc66;">.</span>schema_id<br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #993333; font-weight: bold;">JOIN</span> sys<span style="color: #66cc66;">.</span>indexes <span style="color: #993333; font-weight: bold;">AS</span> i<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #993333; font-weight: bold;">ON</span> o<span style="color: #66cc66;">.</span>object_id <span style="color: #66cc66;">=</span> i<span style="color: #66cc66;">.</span>object_id<br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #993333; font-weight: bold;">JOIN</span> sys<span style="color: #66cc66;">.</span>index_columns <span style="color: #993333; font-weight: bold;">AS</span> ic<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #993333; font-weight: bold;">ON</span> i<span style="color: #66cc66;">.</span>object_id <span style="color: #66cc66;">=</span> ic<span style="color: #66cc66;">.</span>object_id<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #993333; font-weight: bold;">AND</span> i<span style="color: #66cc66;">.</span>index_id <span style="color: #66cc66;">=</span> ic<span style="color: #66cc66;">.</span>index_id<br />
<span style="color: #993333; font-weight: bold;">WHERE</span> &nbsp;i<span style="color: #66cc66;">.</span>index_id <span style="color: #66cc66;">&gt;</span> <span style="color: #cc66cc;">0</span><br />
&nbsp; <span style="color: #993333; font-weight: bold;">AND</span> &nbsp;is_ms_shipped <span style="color: #66cc66;">=</span> <span style="color: #cc66cc;">0</span><br />
<span style="color: #993333; font-weight: bold;">GROUP</span> &nbsp;<span style="color: #993333; font-weight: bold;">BY</span> o<span style="color: #66cc66;">.</span>object_id<span style="color: #66cc66;">,</span> i<span style="color: #66cc66;">.</span>index_id<span style="color: #66cc66;">,</span> s<span style="color: #66cc66;">.</span>name<span style="color: #66cc66;">,</span> o<span style="color: #66cc66;">.</span>name<span style="color: #66cc66;">,</span> i<span style="color: #66cc66;">.</span>name<span style="color: #66cc66;">,</span> is_included_column<br />
<span style="color: #66cc66;">&#41;</span><br />
<span style="color: #993333; font-weight: bold;">SELECT</span> T1<span style="color: #66cc66;">.</span>TABLE_SCHEMA<span style="color: #66cc66;">,</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp;T1<span style="color: #66cc66;">.</span><span style="color: #993333; font-weight: bold;">TABLE_NAME</span><span style="color: #66cc66;">,</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp;T1<span style="color: #66cc66;">.</span>INDEX_NAME<span style="color: #66cc66;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;T1<span style="color: #66cc66;">.</span>NOMBRE <span style="color: #66cc66;">+</span> T0<span style="color: #66cc66;">.</span>NOMBRE <span style="color: #993333; font-weight: bold;">AS</span> NOMBRE_COLONNES<span style="color: #66cc66;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;T0<span style="color: #66cc66;">.</span>NOMBRE <span style="color: #993333; font-weight: bold;">AS</span> NOMBRE_COLONNES_CLEFS<span style="color: #66cc66;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;T1<span style="color: #66cc66;">.</span>NOMBRE <span style="color: #993333; font-weight: bold;">AS</span> NOMBRE_COLONNES_INCLUSES<br />
<span style="color: #993333; font-weight: bold;">FROM</span> &nbsp; T0<br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #993333; font-weight: bold;">JOIN</span> T0 <span style="color: #993333; font-weight: bold;">AS</span> T1<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #993333; font-weight: bold;">ON</span> T0<span style="color: #66cc66;">.</span>object_id <span style="color: #66cc66;">=</span> T1<span style="color: #66cc66;">.</span>object_id<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #993333; font-weight: bold;">AND</span> T0<span style="color: #66cc66;">.</span>index_id <span style="color: #66cc66;">=</span> T1<span style="color: #66cc66;">.</span>index_id<br />
<span style="color: #993333; font-weight: bold;">WHERE</span> &nbsp;T0<span style="color: #66cc66;">.</span>is_included_column <span style="color: #66cc66;">=</span> <span style="color: #cc66cc;">1</span><br />
&nbsp; <span style="color: #993333; font-weight: bold;">AND</span> &nbsp;T1<span style="color: #66cc66;">.</span>is_included_column <span style="color: #66cc66;">=</span> <span style="color: #cc66cc;">0</span><br />
&nbsp; <span style="color: #993333; font-weight: bold;">AND</span> &nbsp;T1<span style="color: #66cc66;">.</span>NOMBRE <span style="color: #66cc66;">+</span> T0<span style="color: #66cc66;">.</span>NOMBRE <span style="color: #66cc66;">&gt;</span> <span style="color: #cc66cc;">10</span> <span style="color: #808080; font-style: italic;">--&gt; seuil limite du nombre de colonnes dans l'index à ne pas dépasser</span></div></div>
<p>Le seuil étant fixé à 10 colonnes, vous pouvez être plus sévère encore ou plus laxiste à votre choix !!!</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">Frédéric Brouard, alias SQLpro, ARCHITECTE DE DONNÉES<br />
Expert &nbsp;S.G.B.D &nbsp;relationnelles &nbsp; et &nbsp; langage &nbsp;S.Q.L<br />
Moste &nbsp;Valuable &nbsp;Professionnal &nbsp;Microsoft &nbsp;SQL Server<br />
Société SQLspot &nbsp;: &nbsp;modélisation, conseil, formation,<br />
optimisation, &nbsp;audit, &nbsp;tuning, &nbsp;administration &nbsp;SGBDR<br />
Enseignant: CNAM PACA, ISEN Toulon, CESI Aix en Prov.</div></div>
<div id="attachment_590" style="width: 548px" class="wp-caption alignnone"><a href="http://blog.developpez.com/sqlpro/files/2015/09/Couverture-livre-SQL-server-Eyrolles.jpg"><img src="http://blog.developpez.com/sqlpro/files/2015/09/Couverture-livre-SQL-server-Eyrolles.jpg" alt="Développez et administrez pour la performance avec SQL Server 2014" width="538" height="652" class="size-full wp-image-590" /></a><p class="wp-caption-text">Développez et administrez pour la performance avec SQL Server 2014</p></div>
<p>L&rsquo;entreprise <a href="http://www.sqlspot.com">SQL Spot</a><br />
<strong>Le site web sur le </strong><a href="http://sqlpro.developpez.com/">SQL et les SGBDR</a></p>
<p><img src="http://blog.developpez.com/media/Microsoft_MVP_logo_vertical Brouard 400.jpg" width="400" height="135" alt="MVP Microsoft SQL
Server" /></p>
]]></content:encoded>
			<wfw:commentRss></wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Point d&#8217;entrée du stockage physique des objets dans SQL Server</title>
		<link>https://blog.developpez.com/sqlpro/p12173/ms-sql-server/point-dentree-du-stockage-physique-des-objets-dans-sql-server</link>
		<comments>https://blog.developpez.com/sqlpro/p12173/ms-sql-server/point-dentree-du-stockage-physique-des-objets-dans-sql-server#comments</comments>
		<pubDate>Mon, 12 Aug 2013 10:27:40 +0000</pubDate>
		<dc:creator><![CDATA[SQLpro]]></dc:creator>
				<category><![CDATA[MS SQL Server]]></category>
		<category><![CDATA[SQL Server 2005]]></category>
		<category><![CDATA[SQL Server 2008]]></category>
		<category><![CDATA[SQL Server 2012]]></category>
		<category><![CDATA[alocation]]></category>
		<category><![CDATA[index]]></category>
		<category><![CDATA[partition]]></category>
		<category><![CDATA[table]]></category>

		<guid isPermaLink="false">http://blog.developpez.com/sqlpro/?p=313</guid>
		<description><![CDATA[La requête suivante permet de connaître le point d&#8217;entrée de tout objets stockant des données dans MS SQL Server. Cette requête utilise une vue interne de nom sys.system_internals_allocation_units. Le résultat de cette vue propose pour chaque objet (table/index/partition) la première page stockant des données de cet objet, la page racine de l&#8217;index (pour une table [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>La requête suivante permet de connaître le point d&rsquo;entrée de tout objets stockant des données dans MS SQL Server.<br />
<span id="more-313"></span><br />
Cette requête utilise une vue interne de nom sys.system_internals_allocation_units.<br />
Le résultat de cette vue propose pour chaque objet (table/index/partition) la première page stockant des données de cet objet, la page racine de l&rsquo;index (pour une table en HEAP, ces deux pages sont identiques) et la première page IAM (Index Allocation Map) indiquant les extensions utilisés par cet objet dans les 64 000 premières extensions du fichier (soit 4 Go).</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:300px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">SELECT s.name AS TABLE_SCHEMA, o.name AS TABLE_NAME, <br />
&nbsp; &nbsp; &nbsp; &nbsp;i.name AS INDEX_NAME,<br />
&nbsp; &nbsp; &nbsp; &nbsp;o.object_id, i.index_id,<br />
&nbsp; &nbsp; &nbsp; &nbsp;p.partition_number,<br />
&nbsp; &nbsp; &nbsp; &nbsp;iau.allocation_unit_id,<br />
&nbsp; &nbsp; &nbsp; &nbsp;i.type_desc AS TYPE_INDEX,<br />
&nbsp; &nbsp; &nbsp; &nbsp;iau.type_desc AS TYPE_ALLOCATION,<br />
&nbsp; &nbsp; &nbsp; &nbsp;CAST(CAST(SUBSTRING (iau.first_page, 6, 1) +<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;SUBSTRING (iau.first_page, 5, 1) AS INT) <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; AS VARCHAR(6)) + ':' + <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; CAST(CAST(SUBSTRING (iau.first_page, 4, 1) +<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; SUBSTRING (iau.first_page, 3, 1) +<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; SUBSTRING (iau.first_page, 2, 1) +<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; SUBSTRING (iau.first_page, 1, 1) AS INT) <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; AS VARCHAR (20)) AS PAGE_1,<br />
&nbsp; &nbsp; &nbsp; &nbsp;CAST(CAST(SUBSTRING (iau.root_page, 6, 1) +<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;SUBSTRING (iau.root_page, 5, 1) AS INT) <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; AS VARCHAR(6)) + ':' + <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; CAST(CAST(SUBSTRING (iau.root_page, 4, 1) +<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; SUBSTRING (iau.root_page, 3, 1) +<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; SUBSTRING (iau.root_page, 2, 1) +<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; SUBSTRING (iau.root_page, 1, 1) AS INT) <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; AS VARCHAR (20)) &nbsp;AS PAGE_RACINE,<br />
&nbsp; &nbsp; &nbsp; &nbsp;CAST(CAST(SUBSTRING (iau.first_iam_page, 6, 1) +<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;SUBSTRING (iau.first_iam_page, 5, 1) AS INT) <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; AS VARCHAR(6)) + ':' + <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; CAST(CAST(SUBSTRING (iau.first_iam_page, 4, 1) +<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; SUBSTRING (iau.first_iam_page, 3, 1) +<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; SUBSTRING (iau.first_iam_page, 2, 1) +<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; SUBSTRING (iau.first_iam_page, 1, 1) AS INT) <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; AS VARCHAR (20)) AS PAGE_IAM_1<br />
FROM &nbsp; sys.objects AS o<br />
&nbsp; &nbsp; &nbsp; &nbsp;INNER JOIN sys.schemas AS s<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;ON o.schema_id = s.schema_id<br />
&nbsp; &nbsp; &nbsp; &nbsp;INNER JOIN sys.indexes AS i<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;ON o.object_id = i.object_id &nbsp;<br />
&nbsp; &nbsp; &nbsp; &nbsp;INNER JOIN sys.partitions AS p<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;ON i.object_id = p.object_id<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;AND i.index_id = p.index_id &nbsp; &nbsp; &nbsp;<br />
&nbsp; &nbsp; &nbsp; &nbsp;INNER JOIN sys.system_internals_allocation_units AS iau<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;ON p.partition_id = iau.container_id;</div></div>
<p><strong>Résultat :</strong></p>
<div id="attachment_315" style="width: 1430px" class="wp-caption alignnone"><a href="http://blog.developpez.com/sqlpro/files/2013/08/IAM_root_SQL_server.png"><img src="http://blog.developpez.com/sqlpro/files/2013/08/IAM_root_SQL_server.png" alt="Résultat présentant les pages racine, d&#039;entrée et IAM (Index Allocation Map) des tables et index de SQL Server" width="1420" height="348" class="size-full wp-image-315" /></a><p class="wp-caption-text">Résultat présentant les pages racine, d&rsquo;entrée et IAM (Index Allocation Map) des tables et index de SQL Server</p></div>
<p><strong>Le site web sur le </strong><a href="http://sqlpro.developpez.com/">SQL et les SGBDR</a><br />
<img src="http://blog.developpez.com/media/Microsoft_MVP_logo_vertical Brouard 400.jpg" width="400" height="135" alt="MVP Microsoft SQL Server" /></p>
<pre>

<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">Frédéric Brouard, alias SQLpro, ARCHITECTE DE DONNÉES<br />
Expert &nbsp;S.G.B.D &nbsp;relationnelles &nbsp; et &nbsp; langage &nbsp;S.Q.L<br />
Moste &nbsp;Valuable &nbsp;Professionnal &nbsp;Microsoft &nbsp;SQL Server<br />
Société SQLspot &nbsp;: &nbsp;modélisation, conseil, formation,<br />
optimisation, &nbsp;audit, &nbsp;tuning, &nbsp;administration &nbsp;SGBDR<br />
Enseignant: CNAM PACA, ISEN Toulon, CESI Aix en Prov.</div></div>

</pre>
<p>L&rsquo;ntreprise <a href="http://www.sqlspot.com">SQL Spot</a></p>
]]></content:encoded>
			<wfw:commentRss></wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
