<?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; descriptif</title>
	<atom:link href="https://blog.developpez.com/sqlpro/ptag/descriptif/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é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>
	</channel>
</rss>
