Finish SQL generate