Remove some portion from data

  • Hello ,

    In my database i have collegename column in that the format is as follow,

    Rizvi Institute of Management Studies And Research, Mumbai - Management

    G.H. Raisoni Institute of Engineering And Technology, Pune - Engineering

    Centum Learning Limited, Pune - Engineering

    i want to fetch the collegename before the dash(-)

    Means collegename will remain as it is as i listed above but at fetching time it should display like "Centum Learning Limited, Pune "

    i used charindex substring but it is not usefull 🙁

    Thanks & Regards,
    Pallavi

  • please take a moment to read the first link in my signature block on posting T-SQL

    as this is fairly a small task i have knocked this up

    create table #temp (col1 nvarchar(max))

    insert into #temp (col1) values

    ('Rizvi Institute of Management Studies And Research, Mumbai - Management'),

    ('G.H. Raisoni Institute of Engineering And Technology, Pune - Engineering'),

    ('Centum Learning Limited, Pune - Engineering')

    and this should do the trick

    select LEFT(col1,CHARINDEX(' - ',col1)) from #temp

  • Yes i tried it before asking you this doubt but

    it is returning collegename

    Rizvi Institute of Management Studies And Research, Mumbai -

    i don't want dash(-) also

    Thanks & Regards,
    Pallavi

  • did you try my script?

  • Yes i tried it

    Thanks & Regards,
    Pallavi

  • It's working 🙂 i forgot to give a front and back space

    Thanks & Regards,
    Pallavi

Viewing 6 posts - 1 through 5 (of 5 total)

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