I have a multi-megabyte .sql file, there are GO statements on newlines every 10k or so. I am trying to come up with a way to read the file, line-by-line, until I hit a new line that only has “go” and a Newline character, then return what was read to the caller, and then read the next bunch of text until I hit GO again.
Peek only lets me read one character, what’s a smart way to make this work in C# on Framework 4.0?
Thanks.
This should do exactly what you were saying.
Call this function with a string of the filename of the SQL file, and it will return an
IEnumerable<string>(a bunch of strings) that each hold a SQL batch (each up until aGOstatement) which you can then loop through withforeachor anything else.