September 11, 2008 at 4:03 am
Hi List,
I have a question in relation to comparing two databases.
I have DB1 and DB2. We recently migrated DB1 to DB2 and would like to check if DB1 and DB2 are identical. Especially, we would like to figure out if each corresponding tables in DB1 and DB2 have similar in contents and whether or not they are identical. Is there a faster way to loop through some 50 tables in DB1 and DB2 and compare the two for similarity?
Thanks indeed for your hint on this.
Niyala
September 11, 2008 at 7:22 am
Do you want to know if the data in the tables is the same ? Or if the table schemas are the same ?? I wrote some scripts to compare schemas.
September 11, 2008 at 7:46 am
Thanks indeed for your response. In fact my interest is to know whether or not the data in Tables (DB1) and Tables(DB2) were the same. Both in DB1 and DB2, I have Tables that are supposed to store similar data. I expect that they should be identical and that is what I after.
Thanks for your hint
Niyala
September 11, 2008 at 8:32 am
You could code something like this:
[font="Courier New"]SELECT MIN(Table_1) as Table_1, Fld1, fld2, fld3
FROM
(SELECT 'Table_1' as Table_1, a.Fld1, a.fld2, a.fld3
FROM Table_1 a
UNION ALL
SELECT 'Table_2' as Table_2, b.Fld1, b.fld2, b.fld3
FROM Table_2 b
) tmp
GROUP BY Fld1, fld2, fld3
HAVING COUNT(*) = 1
ORDER BY fld1[/font]
September 11, 2008 at 8:36 am
Thanks a lot! The interesting issue that the two databases are not on the same instance. DB1 and DB2 are in separate instances.
Niyala
September 11, 2008 at 8:39 am
Hey,
Have you considered products such as RedGate Compare for both schema and data comparisons?
Thanks,
Phillip Cox
September 11, 2008 at 8:54 am
Niyala (9/11/2008)
Thanks a lot! The interesting issue that the two databases are not on the same instance. DB1 and DB2 are in separate instances.Niyala
Then you would need linked servers to run the code.
September 11, 2008 at 9:01 am
There is no way you can get any level of code done that you're sure does this for US$395. Even at the cheapest rates you'd use way more than that amount in time for something that would be custom, would need to be rewritten, and wouldn't be exhaustively tested.
I work for Red Gate, but their tool (or the one from ApexSQL) do this and they're well worth the money.
September 11, 2008 at 10:12 am
As per suggestion try the evaluation version of ApexSQL Diff tool.
MJ
September 22, 2008 at 7:53 pm
Now back the migration pony up just a minute, please! How did you do the migration? It's important to know because some methods absolutely guarantee that the databases, all database objects, and all of the data is absolutely identical and requires no further checking. 😉
--Jeff Moden
Change is inevitable... Change for the better is not.
September 23, 2008 at 7:37 am
SQL Server also ships with a tablediff utility that was really included to check replication, but can be used to compare data across DB's. Here's link to my blog post that includes some information about the utility and also has a link to another blog with more information: http://wiseman-wiseguy.blogspot.com/2008/07/ssis-webinars-and-tablediff.html
Oh, in a previous position I also used the RedGate tools. I have tested the Apex tools as well. I prefer RedGate's.
Jack Corbett
Consultant - Straight Path Solutions
Check out these links on how to get faster and more accurate answers:
Forum Etiquette: How to post data/code on a forum to get the best help
Need an Answer? Actually, No ... You Need a Question
September 23, 2008 at 7:17 pm
Jack Corbett (9/23/2008)
SQL Server also ships with a tablediff utility that was really included to check replication...
Now, that's gonna be handy. Didn't know about that. Thanks, Jack! 🙂
--Jeff Moden
Change is inevitable... Change for the better is not.
September 23, 2008 at 7:28 pm
Glad some of the stuff I read about and give a whirl can be helpful. Every time I think I know what you need to know about SQL Server something new pops up.
Jack Corbett
Consultant - Straight Path Solutions
Check out these links on how to get faster and more accurate answers:
Forum Etiquette: How to post data/code on a forum to get the best help
Need an Answer? Actually, No ... You Need a Question
September 24, 2008 at 9:43 am
Thankfully I have RedGate tools
SQL Compare - compares schema and objects (view, stored procs, table, etc...)
SQL Data Compare - compares DATA inside tables
http://www.red-gate.com/index3.htm
September 25, 2008 at 12:13 pm
Yep me 2,
Working from Development to Test to Production is done in a second with the Redgate Soft,
+ the Sqldoc included comes in handy also..
SQLPrompt is also fine to have but does work difficult with Master.. syntaxes,
+ newly created tables does he not want to recognice,
But for the rest Thumbs up,
Best money ever spended
Wkr,
Eddy
Viewing 15 posts - 1 through 15 (of 15 total)
You must be logged in to reply to this topic. Login to reply