I have auto-converted all database tables from varchar/char to nvarchar/nchar in a database, and wrote some code in VB.NET for that, using SMO. Just ignore the bits that aren't about indexes (most of it, that is...)
[http://www.underlandet.com/SqlServer/2010/02/18/MicrosoftSqlServerManagementSmo.aspx][1]
All the text is in swedish, but I'm sure the code is easy enough to follow.
Pay attention to the line **Dim it As Smo.IndexKeyType = t.Indexes(0).IndexKeyType ** - it's needed for SMO to include the primary keys.
[1]: http://www.underlandet.com/SqlServer/2010/02/18/MicrosoftSqlServerManagementSmo.aspx
↧