simple question with string values...

  • 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?

    _________________________

  • Try using REPLACE, e.g.

    SELECT REPLACE(MyField, 'Once Upon A Time, ', '') As TruncatedData

    FROM MyTable

  • 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.

    _________________________

  • 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.

  • excellent... thanks!

    _________________________

  • 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