Object reference not set exception generating script

david.duffettdavid.duffett Posts: 30
edited September 15, 2010 11:14AM in SQL Data Compare Previous Versions
I am comparing a particular table using a custom comparison key and a WHERE clause and now cannot generate scripts or synchronise databases as an "Object reference not set" error is appearing.

* The table compares records on a column which could be NULL
* The WHERE clause for the comparison restricts records to where this column IS NOT NULL
* Columns included are 2 varchar columns, 2 varchar(max) columns and the comparison key.

The comparison works fine and differences are shown, but I cannot generate scripts, update a folder or synchronise a database, as at the "Generating SQL scripts" stage it shows:

"Object reference not set to an instance of an object."


  • Brian DonahueBrian Donahue Posts: 6,590 New member
    Hi David,

    I can't say what is causing the null-reference exception without debugging SQL Data Compare, but my first advice would be to get the latest cumulative patch and see if that fixes it.

    http://www.red-gate.com/messageboard/vi ... hp?t=10917

    If it still happens in the new version, get in touch with us via email and we will send the debugging instructions.
  • hello David and Brian

    I'm experiencing the same issue, with the latest update installed (

    In my case it occurs when trying to generate the scripts for a comparison between a database and a scripts folder. The records are also limited with a "where" filter (to 1 record).

    Generating a script for a change "Source Only" gives no errors. But when I try to generate a script for 1 record that has different data, the error is thrown.

    More specifically I have chosen "Update scripts folder" and none of the two checkboxes are selected. When I click "Next", the dialog pops up and puts a red cross in front of "Calculating script changes" and at the bottom the "Object reference not set to an instance of an object" message is shown.

    I don't know if this is helpful, but the data being scripts includes a binary column.

    Thanks for looking into this.


    Erwin Dockx
  • I agree - the patch has not solved this problem. I've now had it occur with a much simpler comparison - just one record needed to be added to a table with a non-identity primary key.

    Error appears both in command line and application when trying to update scripts folder, exactly as edockx has described.
  • Is there any update on this? At the moment I'm having to manually add and remove simple records from all our dev and test machines - can't fathom why it won't simply insert or delete records on certain tables due to this error.
  • Brian DonahueBrian Donahue Posts: 6,590 New member
    Please contact support at red-gate.com for debugging steps. Again, I would like to repeat that "object refernece not set to an instance of an object" will never, ever, be solved entirely. If it's not something we know about, it's not in the patch. It will take some investigation to find the particular cause of the problem in your case and that is too complex to deal with here on the forum.
  • I am experiencing the same issue. Comparing a backup to a database using Pro edition. Even if I select a single table it is throwing the error when I hit the Sync Wizzard.

    This is a simple comparision without any filters. Even happening if I only select a single table to sync.

    Tim Goldstein
    Denver, CO
This discussion has been closed.