Showing posts with label spaces. Show all posts
Showing posts with label spaces. Show all posts

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

Saturday, February 25, 2012

No Trim Function?

Hi,
Is there an equivalent to the TRIM() function in SQL Server to remove any
leading or trailing blank spaces in a string variable?
Please advise.
Thanks,
-JoeSELECT LTRIM(RTRIM(' foo '))
"Joe Rigley" <jcrigley@.spartanmotors.com> wrote in message
news:eXkEC0jrFHA.3476@.TK2MSFTNGP10.phx.gbl...
> Hi,
> Is there an equivalent to the TRIM() function in SQL Server to remove any
> leading or trailing blank spaces in a string variable?
> Please advise.
> Thanks,
> -Joe
>|||RTRIM / LTRIM (look in the BOL)
HTH, Jens Suessmeyer.
http://www.sqlserver2005.de
--
"Joe Rigley" wrote:

> Hi,
> Is there an equivalent to the TRIM() function in SQL Server to remove any
> leading or trailing blank spaces in a string variable?
> Please advise.
> Thanks,
> -Joe
>
>|||Ahh! Thanks much!
BOL? What is that and how do I locate?
-Joe
"Jens Smeyer" <Jens@.[Remove_that][for contacting me]sqlserver2005.de>
wrote in message news:FBEB9AF1-211B-4B5B-8572-9D00F041C791@.microsoft.com...
> RTRIM / LTRIM (look in the BOL)
> --
> HTH, Jens Suessmeyer.
> --
> http://www.sqlserver2005.de
> --
>
> "Joe Rigley" wrote:
>|||BOL = Books Online.
http://www.aspfaq.com/2229
"Joe Rigley" <jcrigley@.spartanmotors.com> wrote in message
news:usv1t%23jrFHA.3796@.TK2MSFTNGP11.phx.gbl...
> Ahh! Thanks much!
> BOL? What is that and how do I locate?
> -Joe
> "Jens Smeyer" <Jens@.[Remove_that][for contacting me]sqlserver2005.de>
> wrote in message
> news:FBEB9AF1-211B-4B5B-8572-9D00F041C791@.microsoft.com...
>