Forum Discussion
tristaanogre
14 years agoEsteemed Contributor
Here's a quick mock-up in pseudo-code... it hasn't been tested so I wouldn't copy paste it into anything production. It's based upon Jscript but I think you can get the general usage idea
When writing out to the file, you'll probably have to do some sort of counter or other trick to generate a new file name each time but, hopefully, this gives you a direction to go.
function StripQueriesFromFile
{
var QueryFile;
QueryFile = aqFile.OpenTextFile("C:\Test\MySQL.SQL", faReadWrite, ctUnicode)
while (!QueryFile.IsEndOfFile())
{
var s = QueryFile.ReadLine()
if (aqString.Contains(s, "CREATE TABLE"))
{
s = aqString.Replace(s, "CREATE TABLE", "SELECT * FROM")
aqFile.WriteToTextFile("C:\Test\NewFile.SQL", s, ctUnicode, TRUE)
}
}
}
When writing out to the file, you'll probably have to do some sort of counter or other trick to generate a new file name each time but, hopefully, this gives you a direction to go.