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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Removing Spaces 1

Status
Not open for further replies.

johnrg1

Programmer
Joined
Jan 24, 2003
Messages
38
Location
GB
Hi,

Is there a way to remove empty spaces held by the database? I am using an SQL statement:
SELECT LecturerTitle + ' ' + LecturerInitial + ', ' + LecturerSurname As LecturerName

to select a name out of a database. but the initial field is two characters long, do when it is extracted it becomes Mr D , Parkinson with a space after the initial before the comma.

How can i get rid of the space?

Cheers
 
Hi
you can use the RTRIM function

SELECT LecturerTitle + ' ' + RTRIM(LecturerInitial) + ', ' + LecturerSurname As LecturerName

HTH
 
You can use the REPLACE function to get rid of the additional spaces

Something like
SELECT LecturerTitle + ' ' + REPLACE(LecturerInitial,' ','') + ', ' + LecturerSurname As LecturerName

Andie Harper
"If you can keep your head when all around you have lost theirs, you probably haven't understood the seriousness of the situation"
 
Fantastic. :)

Thank you very much.

John
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top