Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Any way to trim trailing spaces from a text data type?

Status
Not open for further replies.

warburp

IS-IT--Management
Oct 27, 2003
44
GB
Hi

I have an SQL Server database and I am trying to create some reporting from it. All works well execpt when it comes to one field which is a text or ntext data type and I don't seem to be able to do any trim. I want to trim trailing spaces as it makes the report very long otherwise, but I'm a newbie as far as SQL Server goes. I have read that you can't trim, group, etc. with this data type.

Can anyone suggest anything?

Thanks

Phil.
 
Have you tried rTrim()? It should work

Programming today is a race between software engineers striving to build better and bigger idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. - Rick Cook (No, I'm not Rick)

 
select RTRIM(Convert(varchar(8000),textField)) as TextField

you usually can't manipulate Text datatypes...you have to convert them....

DLC
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top