all groups > sql server mseq > march 2004 >
You're in the

sql server mseq

group:

howto ignore whitespace in select query


howto ignore whitespace in select query San Tuon
3/26/2004 3:21:37 AM
sql server mseq:
Hello.

I am getting unwanted whitespaces returned from a select
statement.

I understand my table definition has stated a "char" with
field length 10. However if my value stored is only 5
characters, how do I structure my select query to trim
extra 5 spaces returned in my query. It is possible?

ie "Select id from user"
returns "Santuon " instead of "Santuon".
I do not wish to trim the string afterwards.

Re: howto ignore whitespace in select query San Tuon
3/26/2004 3:48:45 AM
Thanks a million.

For future reference. Is there a way to structure the
database to automatically not return spaces.. ie, the
length of the field should be just the maximum allocated.
I noticed with MS access, the field length is the maximum
size,.. not a fix size. Is my understanding wrong?

Regards San.

[quoted text, click to view]
Re: howto ignore whitespace in select query San Tuon
3/26/2004 4:45:54 AM
That did the trick! Great.

Regards San

[quoted text, click to view]
Re: howto ignore whitespace in select query Vishal Parkar
3/26/2004 4:55:15 PM
hi san,
use function rtrim.

select rtrim(id) from user

--
Vishal Parkar
vgparkar@yahoo.co.in

Re: howto ignore whitespace in select query Vishal Parkar
3/26/2004 5:35:34 PM
hi san,

Use varchar datatype this will take only storage space, of the actual length in bytes of the
data entered.

Use char datatype when the data values in a column are expected to be consistently close to
the same size. For example Sex that is going to be 'F' or 'M'. or marital status like 'Single'
or 'Married' etc.

Use varchar datatype when the data values in a column are expected to vary considerably in
size.

--
Vishal Parkar
vgparkar@yahoo.co.in

AddThis Social Bookmark Button