That's what the pzTail parameter to sqlite3_prepare() is for - it returns a pointer to the remaining text in the input that has not yet been prepared. So you do a loop. You run "sqlite3_prepare()" on the whole SQL, but you remember the pzTail. Then you run sqlite3_step() on the prepared statement until it finishes. Then you run sqlite3_finalize() on the prepared statement. Then as long as you have more SQL text to process, you do the whole thing again.