Adding included columns to indexes using SMO

A question came up on the SQL Down Under mailing list today about how to add an included column to an index using SMO. A quick search of the documentation didn't seem to reveal any clues but a little investigation turned up what's needed: the IndexedColumn class has an IsIncluded property.

Index i = new Index();

IndexedColumn ic = new IndexedColumn(i, "somecolumn");

ic.IsIncluded = true;

 

Leave a Reply

Your email address will not be published.