Selecting part of a String

  • Hi there,

    I have imported a table from excel. But unfortunately the table holds a column containing letters and digits, ex.

    NameCode

    The new institution 357056

    Broadway, Upper 486001

    Southwest, No. 1 987003

    the last 6 characters are always digits. I need to split the column into two seperate columns like,

    Name Code

    The new institution 357056

    Broadway, Upper 486001

    Southwest, No. 1 987003

    Right(NameCode, 6) gives me the Codes in one column, but how do I select the preceding name?

    Best joejoe

  • THis should do the trick:

    SELECT LEFT(NameCode, LEN(NameCode)-6)

    ----------------------------------------------
    Try to learn something about everything and everything about something. - Thomas Henry Huxley

    :w00t:
    Posting Best Practices[/url]
    Numbers / Tally Tables[/url]

    SQL-4-Life
  • Thanks alot 🙂 - just what I needed

    Regards joejoe

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply