The formatting of the SQL needs some work. There are examples of the formatting SQL with the StringBuilder below.