System.NullReferenceException while parsing scripts

jalbertjalbert Posts: 18
edited July 13, 2007 9:27AM in SQL Compare Previous Versions
I'm trying out SQL Compare 6 and have run into a problem with the new scripts feature. We're investigating how we can integrate SQL Compare into our build process. I'm wondering if someone else has experienced this or can offer some insight. When comparing scripts with a blank destination database, I get this:

X Registering databases
Scripts.Create Scripts-Reading xUsers.sql

Object reference not set to an instance of an object.

The file "xUsers.sql" exists, and contains this:
CREATE TABLE dbo.xUsers
(
	UserId INT
)

The T-SQL in question, while trivial, is valid. Yet SQL Compare 6 seems to choke on it when parsing it. Thanks in advance!

Comments

  • Michelle TMichelle T Posts: 566 Gold 1
    The most common cause of that error is that one of the scripts (not necessarily the one it claims to have finished reading on) has a foreign key that refers to a non-existent table. (Other dependencies with a missing target object may also cause this error, like a view referring to a non-existent table.)

    If there's nothing obviously wrong of this nature, or you are reading scripts that were generated by Compare in the first place, tell me and I'll investigate further.
    Software Developer
    Redgate Software
  • I encountered this problem while running scripts that are being developed by hand in a text editor. It's easy enough to mess up and break references that way.

    With that in mind, it would be very helpful for SQL Compare 6 to show which table(s)/view(s) it choked on, rather than just pass the NullReferenceException to the user. Thank you for considering this enhancement.
  • Michelle TMichelle T Posts: 566 Gold 1
    I've added a reference to this thread to the feature request for better error messages on reading inconsistant scripts. Thank you for your report.
    Software Developer
    Redgate Software
Sign In or Register to comment.