Quick check on your query, and if you look at the 3rd parameter to Substring (the LENGTH portion) you have this:
LEN(output_response_xml) - LEN(LEFT(output_response_xml,
CHARINDEX ('>Thank you', output_response_xml))) - LEN(RIGHT(output_response_xml, LEN(output_response_xml) - CHARINDEX ('', output_response_xml))) - 1) as CRCDecision
Lets make some assumptions to make this easier. First, lets assume that output_response_xml ALWAYS contains the text '>Thank you'. Next, lets assume that text is never the FIRST or LAST bit of text in the string.
So for sake of testing, lets say that the output_response_xml value is "hello >Thank you < world". Not a real world thing, but we can use it for testing. This is 24 characters long.
So, using this value, lets break the rest of it up. LEN(output_response_xml) is 24. CHARINDEX('>Thank you', output_response_xml) is 7, CHARINDEX('',output_response_xml) is 0. So, lets do some substitiutions:
24 - LEN(LEFT(output_response_xml, 7)) - LEN(RIGHT(output_response_xml, 24 - 0)) - 1) as CRCDecision
Already this is looking more simple, and the problem is a bit more apparent... but lets keep going. LEN on a LEFT(*,7) will be 7, and doing a LEN(RIGHT(output_response_xml,24)) when the string length is 24 will give us 24, so lets do more substitutions:
24 - 7 - 24 - 1
OR -8. This is an invalid length value for a SUBSTRING. The problem is with that "CHARINDEX('',output_response_xml)" section as that is going to return 0 every time, so you are always going to have a negative value for your substring length.
From reading the SUBSTRING, I think you are wanting to take the string and read starting at "Thank you" until the end of the string, right? I just want to confirm that my interpretation of what this is SUPPOSED to do is correct.
Also, when I say "string", I am meaning VARCHAR or NVARCHAR as I am pretty sure (not positive) that CHARINDEX, LEN, LEFT, RIGHT and SUBSTRING don't work on XML data...