<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>How can I generate a T-SQL script for just the indexes?</title><link>http://blogs.msdn.com/benjones/archive/2008/08/27/how-can-i-generate-a-t-sql-script-for-just-the-indexes.aspx</link><description>I was trying to work out the best way to generate a T-SQL script for only the indexes and I thought that this would be really easy in the Management Studio interface. I was mistaken. SQL Server Management Studio also generates scripts for the tables when</description><dc:language>en-GB</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>discount furniture &amp;raquo; How can I generate a T-SQL script for just the indexes?</title><link>http://blogs.msdn.com/benjones/archive/2008/08/27/how-can-i-generate-a-t-sql-script-for-just-the-indexes.aspx#8901588</link><pubDate>Thu, 28 Aug 2008 00:45:12 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8901588</guid><dc:creator>discount furniture &amp;raquo; How can I generate a T-SQL script for just the indexes?</dc:creator><description>&lt;p&gt;PingBack from &lt;a rel="nofollow" target="_new" href="http://informationsfunnywallpaper.cn/?p=2594"&gt;http://informationsfunnywallpaper.cn/?p=2594&lt;/a&gt;&lt;/p&gt;
</description></item><item><title>re: How can I generate a T-SQL script for just the indexes?</title><link>http://blogs.msdn.com/benjones/archive/2008/08/27/how-can-i-generate-a-t-sql-script-for-just-the-indexes.aspx#8903285</link><pubDate>Thu, 28 Aug 2008 15:39:31 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8903285</guid><dc:creator>Stuntbeaver</dc:creator><description>&lt;p&gt;The libraries you need to reference are a little different from the namespaces (at least they were for me):&lt;/p&gt;
&lt;p&gt;Microsoft.SqlServer.ConnectionInfo&lt;/p&gt;
&lt;p&gt;Microsoft.SqlServer.SMO&lt;/p&gt;
&lt;p&gt;Also I noticed that &amp;quot;so.AppendToFile = false&amp;quot; should be set to true.&lt;/p&gt;
&lt;p&gt;Without this, it will only store script for the very last index (typically a primary key) in the text file. You will of course then need to make sure you truncate the text file at the start of the program.&lt;/p&gt;
</description></item><item><title>re: How can I generate a T-SQL script for just the indexes?</title><link>http://blogs.msdn.com/benjones/archive/2008/08/27/how-can-i-generate-a-t-sql-script-for-just-the-indexes.aspx#8904642</link><pubDate>Fri, 29 Aug 2008 11:16:16 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8904642</guid><dc:creator>Stuntbeaver</dc:creator><description>&lt;p&gt;Forgot to say thanks for posting the example - I found the code quite handy.&lt;/p&gt;
</description></item><item><title>re: How can I generate a T-SQL script for just the indexes?</title><link>http://blogs.msdn.com/benjones/archive/2008/08/27/how-can-i-generate-a-t-sql-script-for-just-the-indexes.aspx#8924808</link><pubDate>Thu, 04 Sep 2008 20:35:22 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8924808</guid><dc:creator>moff</dc:creator><description>&lt;p&gt;You can do this in one line with the new Powershell provider in SQL2008 (even if running against 2005) :-)&lt;/p&gt;
&lt;p&gt;sl SQLSERVER:\SQL\&amp;lt;server&amp;gt;\&amp;lt;instance&amp;gt;\Databases\&amp;lt;db&amp;gt;\Tables;gci|%{gci ($_.DisplayName + '\Indexes')|%{$_.script()}} &amp;gt; c:\indexes.txt&lt;/p&gt;
&lt;p&gt;Fair enough it's not very readable, and it doesn't include the exact scriptingoptions, but hey, it's one line ;-)&lt;/p&gt;
&lt;p&gt;For reference:&lt;/p&gt;
&lt;p&gt;sl = set-location&lt;/p&gt;
&lt;p&gt;gci = get-childitem&lt;/p&gt;
&lt;p&gt;% = foreach-object&lt;/p&gt;
</description></item><item><title>re: How can I generate a T-SQL script for just the indexes?</title><link>http://blogs.msdn.com/benjones/archive/2008/08/27/how-can-i-generate-a-t-sql-script-for-just-the-indexes.aspx#8960517</link><pubDate>Sun, 21 Sep 2008 16:22:42 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8960517</guid><dc:creator>benjones</dc:creator><description>&lt;p&gt;Thanks for all the tips, that's useful info. &amp;nbsp;&lt;/p&gt;
</description></item></channel></rss>