Today I was setting up a new template, and I needed to look at the unique constraints as part of my task.
The following CodeSmith script will load the columns that have unique constraints (but not the primary key) into an ArrayList.
ArrayList uniqueColumns = new ArrayList(); for (int i = 0; i < SourceTable.Indexes.Count; i++) { if (SourceTable.Indexes[i].IsUnique) { for (int y=0; y < SourceTable.Indexes[i].MemberColumns.Count; y++) { if (!SourceTable.Indexes[i].MemberColumns[y].IsPrimaryKeyMember) uniqueColumns.Add(SourceTable.Indexes[i].MemberColumns[y].Name); } } }
Powered by: newtelligence dasBlog 2.3.9074.18820
Disclaimer The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.
© Copyright 2012, © Copyright 2010
E-mail