Result is showing differences when keys match exactly
kevin
Posts: 3
On a few of my tables, the comparison comes up with items Missing on one side and Extra items on the other side but when reviewing the key information, the key fields are identical and therefore should have been match... it does not seem to be able to match up the data all the time although it does work for some records on the table.
This occurs on Tables or Views and in keys which are one or many fields so i can't seem to narrow it down to anything in particular.
Anything I'm missing ?
This occurs on Tables or Views and in keys which are one or many fields so i can't seem to narrow it down to anything in particular.
Anything I'm missing ?
Comments
Also, am I right in thinking you're comparing two live databases here, rather than backups?
Thanks,
Robert
Red Gate
I'm comparing two tables with identical schemas, one on the local (2005) machine, and one on a remote (2000) machine.
I'm using a 2-field index as a key, and because the tables involved are large (1.2 billion rows) and the suspect portions are relatively small, I'm using a WHERE clause on the key to limit the area checked. (Yes, this is the same pair of tables I discuss 3 threads after this one)
When I limit the fields to compare to JUST the keys, the comparison results are thus (a only, diff, b only, same):
92599, 0, 0, 566192 (total 658,791)
This is what I expect to see. However, if I allow it to match ALL fields, then these are the numbers I get:
636788, 36, 544189, 21967 (total 1,202,980)
Needless to say, this freaked me out big time until I figured out that it wasn't real.
So, at this point, I can't use the program to sync these two tables; all I can do is use it to generate inserts for the keys, send it to a file, and manipulate it to build a list of keys to feed into a query to bcp out of the one database and into the other.
The behavior is duplicable every time right now; I'd be happy to work with you in the next couple of days to track down what's causing the glitch.
BTW, after reading another post I think I should add --though it shouldn't have anything at all to do with it -- that the 2005 table is partitioned, the 2000 is not. All data being compared is in the same partition.
This definitely sounds like something isn't working as it should. To help us attempt to replicate this it would be useful to know the datatypes of the 2 fields in the key. Presumably the WHERE clause is filtering using both these fields. The more information you can give us the better.
Regards
Chris
Test Engineer
Red Gate
WHERE clause: trsource/sourceid form a unique key for this group of records (though it is not guaranteed unique for all values of trsource)
That's all I can think of now that might be relevant; please feel free to request any other specific info.
566192 (your key only total) = 544189 + 36 + 21967 + (3 which I assume is the database being used)
So the in1 (a) values are the rest of the database.
I'd check how you've got the WHERE clause setup in the tables & views tab of the options. Apart from that have a look at the .sdc file itself which is in XML and there is a set of 'User actions' at the bottom of the file where the WHERE clause should also be - to make sure it's in there correctly.
Project Manager
Red Gate Software Ltd
We discovered a couple of option settings that managed to resolve the issue although I can't say for sure why. If you are in Edit Project and click on options, we checked all the boxes in the Comparison Behaviour section. Specifically Trim Trailing Spaces and Force Binary Collation.
Hope that helps
You managed to duplicate the problem!
You couldn't duplicate it with those options set...
I had started off with none of the comparison options checked. I checked the top two (trim, force), no change. I tried it with the 3rd (show) checked, still no result. I unchecked "show" just so I could force the 4th (use) to be checked, then re-checked it so that all 4 boxes show checked...and still no diffrence. It didn't solve the problem on my system.
Thanks!
Like I said before it's as if when you include all the extra columns for comparison it stops using the WHERE clause. I was confused by your comment of 'Needless to say, this freaked me out big time until I figured out that it wasn't real.' - what do you mean it wasn't real?
Also can I check you're using SQL Data Compare 6.
If you can send me your .sdc project files to richard.mitchell@red-gate.com
I'll have a look at them and see if there is anything obvious wrong with the user actions.
Not sure what else to suggest at the moment as it doesn't seem to be a schema problem. The only other thing is if you have strange characters in your other columns names. You can run a profiler on the database in both situations to see exactly what SQL SDC6 is sending to request the rows - that may help.
Project Manager
Red Gate Software Ltd
Machine A is replicating to machine B. I knew that there were records on A that never made it over to B (92k, as confirmed later by doing the Key-only compare), but it was rather shocking to see it initially report not only 500k of those, but another 600k that supposedly existed on B but weren't on A! (I also spot-checked those records and verified that they DID indeed exist on A, contrary to what it claimed.)
Yes, build #1124. BTW, I like the photo that appears after 30 seconds in the about box. It's a bit classier than one of my products where it brings up a cheap pong game with everyone's heads as the balls. 8)
Okay. I glanced through it and didn't see anything conclusive. I'll pass it on to you.
That's a good suggestion. I also might play with some other things to simplify it and see where I can get the problem to drop out. For example, I'm using a compound key, but my WHERE clause limits the 1st field of the key to a single value, so there's no real need to use that field in the join. Anyway, I'll need to wait until tonight, because the queries murder my data load (in addition to guaranteeing inconsistencies).
Thanks again!
Oh, how fun -- it *is* a game! Turns into a little puzzle after a while. I like it!
I had been making changes to the WHERE clause and didn't want to lose track of them, so the code looked something like this:
Bad decision to use that style of comment -- you never know what's going to be appended to it! Indeed, it was coming out as:
Of course, the ORDER BY was commented out!
Adding an extra blank line after the comment would fix the problem, but if you must include a comment, it's safer to use this style: so there's a definite closure.
Strangely, list compares work much better when the two lists are in the same order.... :roll:
Thanks for the help, guys!
The SQL Profiler would have shown that up in it's trace I'm sure of it.
We must replace that game at some point too, there's a nice bug in it where it's only actually solvable 50% of the time :twisted:
Glad it's working for you and I'll place a bug in our system to get it patched for the next release.
Project Manager
Red Gate Software Ltd