How amazing that in almost 4 years noone replied properly to this question. Probably even the staff members don’t realize what’s going on.
If you have a long query that takes several lines inside the “expression editor” (or inside the “Edit query…” button / “Edit SQL” dialog – which, by the way, is double confusing: 1 - because the button has a different name than the dialog it opens and 2 - because the “expression editor” dialog and the “Expression whatever” dialog look quite similar and the difference amongs them is not clear and it’s probably nothing else than adding the “variables” for the parameters for the parametrized query -again double confusing because the tutorial in How To Pass Dynamic Data To SQL Query From UiPath? - News / Knowledge Base - UiPath Community Forum talks about two methods, “passing variables” and “passing parameters”, but then the “variables” nomenclature are used in the dialog of passing the actual PARAMETERS) that takes MORE THAN ONE LINE, then simple duplicating the double quotes for escaping the column name aliases that have an space in the middle will simple not work.
You need to split each different line, surround them in double quotes and join them together, this style:
"SELECT E.MYDATE, "“MY DATE 1"”, F.MYDATE ““MY DATE 2"”, F.PATH " &
" FROM SENTS1 E " &
" JOIN SENT2.F ON E.ID=F.ID " &
" WHERE E.COD_FILE In " &
" (SELECT CV.VAL " &
" FFROM CMPS_VALUE CV) " &
" AND E.ID_EXP = @idExp”
Such a hassle.