How to find data with Carriage Return in string in SQL Server

Scenario:


You are working as SQL server DBA and you have a table Test with column Name , you need to find if Name column contain any data which has carriage return, how would you find string with carriage return in SQL Server?

Solution:

You can use below sql statement to find our carriage return in SQL Server.

Select Name From dbo.Test
where Name like '%'+char(13)+'%' or Name like '%'+char(10)+'%'

No comments:

Post a Comment