Yo tengo esta (no es mía sino de un compañero):
Código Delphi
[-] if query.sql.Text <> '' then
begin
consulta := stringReplace(query.sql.Text, #13#10, ' ', [rfreplaceall]);
for i:= 0 to query.ParamCount-1 do
begin
try
if query.Params[i].DataType = ftString then
consulta := stringReplace(sSql, ':'+ query.Params[i].Name, QuotedStr(query.Params[i].AsString), [rfreplaceall, rfIgnoreCase])
else if query.Params[i].DataType = ftDateTime then
consulta := stringReplace(sSql, ':'+ query.Params[i].Name, QuotedStr(FormatDateTime('yyyy/mm/dd', query.Params[i].AsDateTime)), [rfreplaceall, rfIgnoreCase])
else consulta := stringReplace(sSql, ':'+ query.Params[i].Name, query.Params[i].AsString, [rfreplaceall, rfIgnoreCase]);
except
end;
end;
end;