sql - trim the column value string -


in sql query, need values below using select query of column. result has text after first space ' ' , before first '('

source column

create table test_table (column1 varchar(50)) insert test_table values ('0636 kavithi (loc)'), ('0638 sri krishna (nat)'), ('0639 selvam'), ('0643 service (loc)'), ('0644 fina care event (loc)') 

i need string found between first ' ' , '('

expected result

kavithi sri krishna selvam service fina care event 

another approach without using outer apply.

select case when column1 '%(%'              substring(right(column1,len(column1)-charindex(' ',column1)),0,                  charindex('(',right(column1,len(column1)-charindex(' ',column1)),0))              else right(column1,len(column1)-charindex(' ',column1))              end trimmed test_table 

output

trimmed kavithi sri krishna selvam service fina care event 

sql fiddle: http://sqlfiddle.com/#!3/69dd1/20/0


Comments

Popular posts from this blog

html - Firefox flex bug applied to buttons? -

html - Missing border-right in select on Firefox -

python - build a suggestions list using fuzzywuzzy -