varchar(10), , , ,
1234|5|6789X
____________
2134|1|71891
|5| |1| .
, STUFF
SELECT CASE WHEN LEN (col) >4 THEN STUFF(col,5,1,'X')
ELSE col END FROM tbl
where tblis the name of your table, and colis your column name and replace 'X'with what you want to replace.
Explanation: The reason for use CASEis that if STUFFit encounters a string that does not have a 5th character in the above statement, it returns NULL.
source
share