Improve error handling when database has syntax errors
When first starting to use SQL Release, it's likely that the target database may have a few syntax errors in it. For example, it could have a sproc that references a table that doesn't exist. Alternatively, the TempDB that SQL Release is using might not support a feature that the target database uses, or the real SQL Database might not support a feature that the target database is using. In any of these cases, the error returned by New-DatabaseRelease is very unhelpful:
new-databaserelease : SQLCompare.exe terminated with the exit code 126: Failed due to a SQL Server error.
SQLCompare.exe produced this error output:
Error: Comparison of 'Scripts.t1orfoxw.w2l' and 'Scripts.zyaq4wvo.ucx' failed: An error occurred while creating a
temporary database.
At line:1 char:16
+ ... leaseToQA = new-databaserelease -source D:\Build-Fut ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [New-DatabaseRelease], TerminatingException
+ FullyQualifiedErrorId : CompareSQLServerError,RedGate.SQLRelease.PowerShell.Commands.NewDatabaseReleaseCommand
The only way that I've found to actually fix these issues is to run SQL Profiler against the database that is being used for the temp Database and capture the trace of what SQL Compare is trying to do and what errors SQL Server returned.
The error diagnostics in this case need to be improved.
In the years since this was last updated, many changes have taken place. SQL Change Automation does now give more detailed error messages and I believe this has been resolved.