Red Gate forums :: View topic - Bug: Template uses "\r\nGO" to detect batches for /postsql
Return to www.red-gate.com RSS Feed Available

Search  | Usergroups |  Profile |  Messages |  Log in  Register 
Go to product documentation
SQL Packager 6
SQL Packager 6 forum

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

Search in SQL Packager 6 forum
Post new topic   Reply to topic
Jump to:  
Author Message
colbybhearn



Joined: 27 Sep 2012
Posts: 5

PostPosted: Thu Sep 27, 2012 4:48 pm    Post subject: Bug: Template uses "\r\nGO" to detect batches for /postsql Reply with quote

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.

Workaround:
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.

Suggestion:
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.
-Colby
Back to top
View user's profile Send private message
Brian Donahue



Joined: 23 Aug 2004
Posts: 6646

PostPosted: Mon Oct 01, 2012 11:31 am    Post subject: Reply with quote

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_packager/SQL%20Packager_6.4.1.2.exe

If you already have 6.4.1, please let me know.
Back to top
View user's profile Send private message
colbybhearn



Joined: 27 Sep 2012
Posts: 5

PostPosted: Mon Oct 01, 2012 2:34 pm    Post subject: Reply with quote

Hey Brian,
Thanks for checking on this.
Yup, my version of SqlPackager is 6.4.0.8
Glad it's already taken care of!
-Colby
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic All times are GMT + 1 Hour
Page 1 of 1

 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group