I have a very large sql file I want to break up into batches for execution. I want to make sure I'm parsing it the same way that SSMS and SQLCMD do.
Microsoft has a great mixed mode assembly named Microsoft.SqlServer.BatchParser with a class named Parser that seams like it would do the trick.
It wants an implementation of IBatchSource as an argument to SetBatchSource before calling Parse().
Where can I find an implementation of IBatchSource, and more information on how to make use of this functionality?
I found the assembly Microsoft.SqlServer.BatchParser in the GAC along with it's friend Microsoft.SqlServer.BatchParserClient that contains implementations the interface IBatchSource.
The following conversation then occurred.
Repeatable Instructions (Do try this at home!)
Program.cs
App.Config
Another option is to use the ScriptDom as described in this answer: https://stackoverflow.com/a/32529415/26877.