Minor.

Moved the 4 lines of sql cmds to end of file so it can be piped