learn_plsql learn_plsql - 1 year ago 84
SQL Question

Oracle -- finding values with leading or trailing spaces

I am trying to find if a certain column requires

function on it.

How can I find out if this column in a table has records that have white space either before or after the actual data.

Answer Source

You can check it using the TRIM function itself, not the most efficient but accurate:

Select *
From TableA
Where MyColumn <> TRIM(MyColumn)

Though if you're checking then turning around to trim anyway, you probably want to just do it in the first place, like this:

Select TRIM(MyColumn) as TrimmedMyColumn
From TableA
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download