Calling All Ghurus

  • Simple question for the right Ghuru.

    What is the correct to do this:

    SELECT [?] FROM Course

    Sample Entries in Course Table

    SimID:

    C9999_000

    C6756_000

    C5436_000

    C65788_000

    C546777_000

    Desired result set:

    C9999

    C6756

    C5436

    C65788

    C546777

     

  • either

    select replace( SimID, '_000','')  FROM Course

    or

    select left(SimID,len(SimID)-4)  FROM Course

    All depends how you want to do it , and what the data looks like.



    ----------------
    Jim P.

    A little bit of this and a little byte of that can cause bloatware.

  • Thanks Jim,

     

  • You can also use CHARINDEX to find the place where the underscore is and take a substring up to that point.

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

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