Red Gate forums :: View topic - Detailed Database Comparison Output
Return to www.red-gate.com RSS Feed Available

Search  | Usergroups |  Profile |  Messages |  Log in  Register 
Go to product documentation
SQL Comparison SDK Previous Versions
SQL Comparison SDK Previous Versions forum

Detailed Database Comparison Output

Search in SQL Comparison SDK Previous Versions forum
Post new topic   Reply to topic
Jump to:  
Author Message
abjacs



Joined: 19 Dec 2008
Posts: 6

PostPosted: Fri Dec 19, 2008 8:44 pm    Post subject: Detailed Database Comparison Output Reply with quote

Hi.

I am working on an application, and one piece of functionality is to output a detailed comparison between two databases, scripts folders, etc.

So far, my comparison output isn't very detailed and only shows output such as:
"OnlyIn1 Table dbo.Users"
"Different Role Superman"
etc.

Instead, I'd like very detailed output such as:
"Table <name of table here> has Index IX_UserKey"

Additionally, the SQL Compare GUI will show that one table in database A has changed compared to the same table in database B and will specifically show the SQL statement that is different.
How can I realize this type of output in my application?

Thanks for the help! Laughing
Back to top
View user's profile Send private message
Michelle Taylor



Joined: 30 Oct 2006
Posts: 525
Location: Red Gate Software

PostPosted: Mon Dec 22, 2008 12:36 pm    Post subject: Reply with quote

You can find the information such as "Table x has Index y" by looking through the individual objects held within each Difference object (or within the Database object for the database in question). For this specific example you would need to cast the IDatabaseObject to ViewTableSuperClass and then iterate through the Indexes property to get the table's indexes, and retrieve their names from the resulting Index objects.

The side by side comparison is mostly done in the user interface code. You can make a start at it with the API by using the ScriptObject method of a Work object on the object you want the SQL script for, but you'll have to implement your own comparison between the script of the two objects.

Hope that helps and is about the detail level you were looking for.
Back to top
View user's profile Send private message
abjacs



Joined: 19 Dec 2008
Posts: 6

PostPosted: Tue Dec 23, 2008 7:24 pm    Post subject: String Diff Reply with quote

Thanks for the reply.

So as I understand it I basically have two choices.
If I know that two tables are "different" i.e. DifferenceType.Different than I can:

1) Compare the regions in each table and somehow do a string comparison to output the exact difference(s) between the tables (I assume this is as close as I could get to the SQL Compare GUI)

or,
2) Take the database object for each database, iterate through and compare indexes, FK's, etc. between all the tables to find the exact difference(s).

Is this correct?
Thanks.
Back to top
View user's profile Send private message
Michelle Taylor



Joined: 30 Oct 2006
Posts: 525
Location: Red Gate Software

PostPosted: Wed Dec 24, 2008 1:50 pm    Post subject: Reply with quote

Yes, that's correct.

(You can extract the object you're looking at straight from the Differences collection without having to go via the Database object if you like, though - there are ObjectIn1 and ObjectIn2 fields in the Difference objects which contain the object itself. You'll have to cast it from IDatabaseObject to the correct database object class, but that shouldn't be too difficult as IDatabaseObject tells you the object type.)
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic All times are GMT + 1 Hour
Page 1 of 1

 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group