Doah! I had tried this earlier but it wasn't working. It turns out that I created my DB with the wrong name (missed a letter my eyes weren't catching even though I looked). My SQL statement used the name it was supposed to be, but wasn't, hence it kept failing.
I win the idiot for the day award. Thanks for the help as I wouldn't have tried this again otherwise.