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
If by special characters you mean non-printable characters you could use this one:
select yourfield, hex(trim(yourfield)),TRANSLATE(
yourfield,
' ',
x'000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F202122232425262728292A2B2C2D2E2F303132333435363738393A3B3C3D3E3F')
from yourtable
where yourfield <> TRANSLATE(
yourfield,
' ',
x'000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F202122232425262728292A2B2C2D2E2F303132333435363738393A3B3C3D3E3F')
You'll probably see that your odd characters HEX() is < 40.
Anyway if you know the HEX() of your odd/special characters you could use this approach and then replace them for a space or whatever you want permanently:
Update yourtable
set yourfield= Translate(yourfield,
' ',
x'000102030405060708090A0B0C0D0E101112131415161718191A1B1C1D1E202122232425262728292A2B2C2D2E303132333435363738393A3B3C3D3E0F1F2F3F')
where yourfield <> Translate(yourfield,
' ',
x'000102030405060708090A0B0C0D0E101112131415161718191A1B1C1D1E202122232425262728292A2B2C2D2E303132333435363738393A3B3C3D3E0F1F2F3F')