Wednesday, March 28, 2012

Normalize data?

I have two columes F1 and F2
Both are NUMBER but were orginally imported from a TXT file.
Is there any way to ENSURE, that there are no spaces and such inside the
fields to ensure proper matching? i.e. if I am trying to match F2 with F2
and one records is "1" and the second is "1 " (space added to the end) it
won't match, how do i remove spaces like this?
DennisIf both columns are numeric datatypes then they won't have leading or
trailing spaces. I don't know what you mean by "Both are NUMBER". There
is no built-in datatype called "NUMBER". Maybe you have a user-defined
type in which case you could just change the column to be a proper
NUMERIC or INTEGER for example.
David Portas
SQL Server MVP
--|||db wrote:
> I have two columes F1 and F2
> Both are NUMBER but were orginally imported from a TXT file.
> Is there any way to ENSURE, that there are no spaces and such inside
> the fields to ensure proper matching? i.e. if I am trying to match
> F2 with F2 and one records is "1" and the second is "1 " (space added
> to the end) it won't match, how do i remove spaces like this?
> Dennis
If your NUMBER columns are actually a character datatype, you should
trim your values before you insert into the table. You can also issue a
trim on the columns now to remove any leading white space.
David Gugick
Imceda Software
www.imceda.comsql

No comments:

Post a Comment