Since 2002, over 10% of total cyber vulnerabilities were SQL injection vulnerabilities (SQLIVs). Since most developers are not experienced software security practitioners, a solution for correctly removing SQLIVs that does not require security expertise is desirable. In this paper, an automated fix generation algorithm for removing SQLIVs by replacing SQL statements with prepared SQL statements is described. Automated fix generation is a type of automated code generation that analyzes project artifacts containing faults and uses the analysis to generate fault free alternative or replacement code. Prepared SQL statements have a static structure and take type-specific input parameters, which prevents SQL injection attack input from changing the structure and logic of a statement. The automated fix algorithm is evolved over the course of preparing for and analyzing the results of four formative and evaluative case studies.