Skip to main content

Posts

Showing posts from December, 2019

Removing all types of blanks of a value in TSQL

Blanks are hectic when it comes to joins, you will see absolutely no different between two values but they won't map with each other. This is a common scenario when you have data loaded from flat files and specially Excel. My below replace statement will work fine and remove all sort of blanks and leave you with pure value for a hassle free join. LTRIM(RTRIM(REPLACE(REPLACE(REPLACE(REPLACE([ Value to be cleaned ] , CHAR(10), ''), CHAR(13), ''), CHAR(9), ''), CHAR(160 ), '')))