locked
Remove the Space and Special Character from the each first word in string of column RRS feed

  • Question

  • Hi,

    I have a columnA in Table T1 with Job Title.

    Having values

    "Computer Programmer"

    "   Database Analyst"

    "-*%Data Architect"

    "   #Team LEad"

    I have to get rid of all the spaces or Special characters that is in front of each firast word of title as below:

    "Computer Programmer"

    "Database Analyst"

    "Data Architect"

    "Team LEad"

    How can write the script for this. Do i have to write function for this. Any help is appreciated.

    Thanks,

    Punia

    Friday, April 12, 2013 8:55 PM

Answers

  • create table test (col   varchar(20));
    insert into test values ('Computer Programmer'),('  Database Analyst'),('"-*%Data Architect'),('   #Team LEad')
    
    select col,  substring(col,  patindex('%[a-zA-Z]%',col),len(col))  as newCol
    from test
    
    drop table test

    Friday, April 12, 2013 9:20 PM

All replies