There is one small problem with using the split method to execute packages. The problem is in the comments. Say you do not have authority over the contents of the files. You just need to execute it. GO in multi-line comments will be a problem in every example solution here, which breaks the sql code, using "GO" as a delimiter. Example:
[some sql code] GO /* start of commented out sql code *********** [some sql code] GO end of commented out sql code ****************/ [some sql code] GO
This will require more complex parsing than just separation. This will no longer work:
Regex regex = new Regex("^GO", RegexOptions.IgnoreCase | RegexOptions.Multiline); string[] lines = regex.Split(sql);
This code also ignores that spaces can lead to GO.
Eugene
source share