Execution Plan StatementText contains incorrect syntax I have run an execution plan with management studio 2014 on mssql 2008 R2. 
To be able to better read the Selectstatement i right-clicked the plan to view it in xml. 

I noticed that some statements seem to contain invalid charachters SELECT @IsHeadVersion = IsHead&amp;#xD;&amp;#xA;FROM myTable. At least if i copy them into a new query window i get an invalid syntax error

  &lt;StmtSimple StatementCompId="10" StatementEstRows="1" 
  StatementId="2" StatementOptmLevel="TRIVIAL" 
  StatementSubTreeCost="0.0032831" 
  StatementText="SELECT @IsHeadVersion = IsHead&amp;#xD;&amp;#xA;FROM myTable
   WHERE Id = @VersionID&amp;#xD;&amp;#xA;&amp;#xD;&amp;#xA;
  -- if head  and no delta, select platformIDs and vehicleIDs in this version&amp;#xD;" 
   StatementType="SELECT" QueryHash="0x29CDF8384A77017F" QueryPlanHash="0xF39275675F085D1B"&gt;
   &lt;StatementSetOptions ANSI_NULLS="true" ANSI_PADDING="true" 
        ANSI_WARNINGS="true" ARITHABORT="true" 
        CONCAT_NULL_YIELDS_NULL="true" 
        NUMERIC_ROUNDABORT="false" QUOTED_IDENTIFIER="true" /&gt;


The Statment is dynamically generated inside a stored procedure. 

My qustion is could the invalid characters be added by management studio in the xml view?

Or do i have incorrect escape sequences inside the generated sql
&amp;#xD;&amp;#xA; are carriage return/line feed. You could use SSMS find/replace to either remove them, or set them to start new lines. Just use the regular expression option.