text: I); }
  } } }
  PingBack from
  The libraries you need to reference are a little different from the namespaces (at least they were for me):
  Microsoft.SqlServer.ConnectionInfo
  Microsoft.SqlServer.SMO
  Also I noticed that "so.AppendToFile = false" should be set to true.
  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.
  Forgot to say thanks for posting the example - I found the code quite handy.
  You can do this in one line with the new Powershell provider in SQL2008 (even if running against 2005) :-)
  sl SQLSERVER:\SQL\<server>\<instance>\Databases\<db>\Tables;gci|%{gci ($_.DisplayName + '\Indexes')|%{$_.script()}} > c:\indexes.txt
  Fair enough it's not very readable, and it doesn't include the exact scriptingoptions, but hey, it's one line ;-)
  For reference:
  sl = set-location
  gci = get-childitem
  % = foreach-object
  Thanks for all the tips, that's useful info.
  Trademarks |
  Privacy Statement