How to find special characters in DB2?

前端 未结 6 873
北海茫月
北海茫月 2020-12-06 07:22

I have a DB2 database containing millions of records. I found that some char() or varchar() fields contain special characters which shouldn\'t be stored. I guess application

6条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-06 07:46

    This query has worked for me in the past on iSeries DB2.

    select * from db/table where posstr(field, x'3F') > 0 
    

    Trouble is you have to be certain of the hex value you are searching for in the string. I had a similar situation where the I was sure the hex code for the character was x'3F, but when I sub-string the non-viewable character it was actually x'22. You might want to single out the character that is giving you the issue and see what it's value is.

    select hex(substr(field, 21,1)) from db/table where posstr(field, 'StringBeforeCharacter') > 0 
    

提交回复
热议问题