Generate SQL UPDATE from Excel CSV file
You can turn this into "here doc" solution by using wrapping it in a process substitution &lt;(...), like this:

awk -f &lt;(cat &lt;&lt; "EOF"
{
    ... // awk script, as if in a file
}
EOF
)


This way, you can write ' directly, as if in a .awk script file,
because there ' is no longer an enclosing character.

Note that cat &lt;&lt; "EOF" is necessary instead of simply cat &lt;&lt; EOF to avoid variable expansion of $1, $3 and $4.

Also, to avoid multiple print statements,
you will have to embed newlines with \n, and end lines with \ to continue the same print statement on the next line.

Finally, you don't need the sed -e 1d, because awk can do this alone, using a NR &gt; 1 filter. However, to account for the extra line in the input, whenever you use NR in the awk script, you would have to change that to NR - 1.

Putting the above together, this script is equivalent to yours (produces same output):

awk -F';' -f &lt;(cat &lt;&lt; "EOF"
NR &gt; 1 {
print "\
DECLARE @v_trmPfiID_fk varchar(16) = '"$1"'\n\
DECLARE @v_trmNom varchar(6) = '"$3"'\n\
DECLARE @v_trmNbrTrav smallint = "$4"\n\
IF EXISTS (SELECT 1 FROM trimestre WHERE trmPfiID_fk = @v_trmPfiID_fk AND trmNom = @v_trmNom)\n\
    BEGIN\n\
        UPDATE trimestre\n\
        SET trmNbrTrav = @v_trmNbrTrav\n\
        WHERE trmPfiID_fk = @v_trmPfiID_fk AND trmNom = @v_trmNom\n\
    END\n\
ELSE\n\
    BEGIN\n\
        PRINT 'The script execution FAILED for record " (NR - 1) " (pfiID ' + @v_trmPfiID_fk + ', trimestre ' + @v_trmNom + ').'\n\
    END\n\
go\n\
"
}
EOF
) &lt; in.csv