I’m currently using SMO and C# to traverse databases to create a tree of settings representing various aspects of the two databases, then comparing these trees to see where and how they are different.
The problem is, for 2 reasonably sized database, it takes almost 10mins to crawl them locally and collect table/column/stored procedure information I wish to compare.
Is there a better interface then SMO to access databases in such a fashion? I would like to not include any additional dependencies, but I’ll take that pain for a 50% speed improvement. Below is a sample of how I’m enumerating tables and columns.
Microsoft.SqlServer.Management.Smo.Database db = db_in; foreach (Table t in db.Tables) { if (t.IsSystemObject == false) { foreach (Column c in t.Columns) { } } }
Try to force SMO to read all the required fields at once, instead of querying on access. See this blog for more information
EDIT: Link is dead but I found the page on archive.org. Here’s the relevant code: