August 11, 2006 at 2:47 pm
suppose you have a column with nothing but varchar.
each record is really a long list of sentances.
example: Once upon a time there was a bird...
what if i wanted to select not just all the record, but only
certain words within it.
example: (there was a bird)
i'm trying to select out that particular part of it
using hyphens, escape characters etc, but i'm having trouble.
each record has the(Once upon a time) which is what i don't
need. i would rather have (there was a whatever) from each
record.
how can you exclude certain words from appearing in your output?
thoughts?
_________________________
August 11, 2006 at 2:51 pm
Try using REPLACE, e.g.
SELECT REPLACE(MyField, 'Once Upon A Time, ', '') As TruncatedData
FROM MyTable
August 11, 2006 at 3:03 pm
so... this will only replace the ouput given, and not the actual
values within the table right?
just want to make sure.
also... when you say MyField, do you mean the column name?
thanks by the way.
_________________________
August 11, 2006 at 6:56 pm
To replace the output, you use it in the SELECT (as shown). If you wanted to replace data in the table, you would need to use it with an UPDATE statement.
Yes, MyField is generic for whatever column you need to modify / display differently.
August 14, 2006 at 7:47 am
excellent... thanks!
_________________________
August 14, 2006 at 12:45 pm
last question...
any ideas on a more complex replace script?
what if you wanted to keep the first set, remove every
thing between, and then include the last set? maybe with one of these +,
or what about escape characters?
thoughts?
_________________________
Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply