Bug: Template uses "\\r\\nGO" to detect batches for /postsql

Forum for users of SQL Packager database archive utility

Bug: Template uses "\\r\\nGO" to detect batches for /postsql

Postby colbybhearn » Thu Sep 27, 2012 3:48 pm

I just spent a couple hours getting the /postsql switch to work on an .exe created with Packager. It worked fine for one script but not another, so I went digging. I found that the code template has a method RunSQLFile(string,string) that reads an sql file, chops it into batches using "GO" statements and calls the ExecuteSQLCommand(string) method.

I removed all the GO statements from my query, but no real change in output or functionality. I did some debugging on RunSQLFile and discovered it was still finding a "GO" somehow! Turns out the script had a GOTO statement on a newline, which matches "\\r\\nGO" perfectly. Thus, it was detecting a batch that didn't exist.

The workaround is fairly simple. I can just prevent my GOTO from matching "\\r\\nGO" by inserting white-space or by putting the GOTO at the end of the previous line.

In my own sql script processing library, I use "\\r\\nGO\\r\\n", but I don't know if that's always appropriate. Also, specifically stating that GO is used to breakup the script into batches would be helpful to have documented somewhere - maybe on the info tab of the resulting .exe or maybe in the help embedded in sqlpackager.exe available from the command line.

I hope this helps make a great tool even better.
Posts: 5
Joined: Thu Sep 27, 2012 3:26 pm

Postby Brian Donahue » Mon Oct 01, 2012 10:31 am

Can you please let me know which version of SQL Packager this affects? I believe this issue has been addressed in a private patch:
ftp://support.red-gate.com/patches/sql_ ... .4.1.2.exe

If you already have 6.4.1, please let me know.
Brian Donahue
Posts: 6590
Joined: Mon Aug 23, 2004 9:48 am

Postby colbybhearn » Mon Oct 01, 2012 1:34 pm

Hey Brian,
Thanks for checking on this.
Yup, my version of SqlPackager is
Glad it's already taken care of!
Posts: 5
Joined: Thu Sep 27, 2012 3:26 pm

Return to SQL Packager Previous Versions

Who is online

Users browsing this forum: No registered users and 0 guests