The SELECT query breaks if the Account name has single quotes (’) in it, such as Gary’s ROTH IRA. I’ll have to dig up my old SQL books to see how to escape the single quote or otherwise trim out the quote. Maybe someone has already fought this battle.
I know I could rename the Account and replace all of the existing transactions, but the code could be a little more robust unless there are warnings published somewhere about not using certain characters in the Account names.