November 16, 2006 at 6:35 am
Hi all,
I have a returned result as follows:
Computer and Mathematical Occupations
Healthcare Practitioners and Technical Occupations
Management Occupations
Office and Administrative Support Occupations
what I want to do is to make the sql query return these data without the word "Occupations" which is at the end of statement.
Is there a sql function can do so?
Thanks in advance.
November 16, 2006 at 6:56 am
Hi,
Yes you can used the replace function for this purpose.
SELECT REPLACE(FieldName,'Occupations','')
Hope this will slove your problem
Cheers
cheers
November 16, 2006 at 7:02 am
Thanks alot.
It ran correcly
November 16, 2006 at 7:36 am
Ya but it works only if the word occupation is only found once in the sentence.
You might want to add this where condition :
SELECT CASE WHEN FieldName LIKE '% occupation' THEN LEFT(FieldName, LEN(FieldName) - 11 /* length of occupation.. adjust depending on spaces*/
ELSE FieldName
Viewing 4 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply