Search This Blog

June 29, 2015

Exclude the data of carriage return char (13) in SQL query

Today one test failed in SOAtest. After looking into this one, I noticed that if I invoked one WCF method using the same scenario, it returned the following data in WCF response.

"INSERT\r TEST\r TESET\r \r REASON"

But In SQL server, it showed “INSERT TEST TESET REASON"

That’s because the data contains Carriage Return CHAR (13).

 

If I add Where [ReasonCode] like '%'+char(13)+'%' in SQL query, I can find the data of Carriage Return.

 

If I add Where [ReasonCode] not like '%'+char(13)+'%' in SQL query, I can’t  find the data of Carriage Return.



In order to avoid these kind of data, after adding Where [ReasonCode] not like '%'+char(13)+'%' in SQL query, the test passes all the time.

No comments: