Yes, the compiler is smart enough to optimize constant string concatenations. To prove this, consider the following method:
public static string Concat() { return "a" + "b"; }
Compiled in Release mode, this calls the following IL:
.method public hidebysig static string Concat() cil managed { .maxstack 8 L_0000: ldstr "ab" L_0005: ret }
Pay attention to optimization. Thus, in terms of performance, both methods are identical. The only difference is that in the second case, you will get new lines (\ r \ n) in the line, so they won’t create exactly the same line, but SQL Server is also smart enough :-)
Darin Dimitrov
source share