Move SQL query and signature generation into TargetSql