sql server - Selecting Substring SQL -


i need select substring found between (). starting , ending position vary, length of substring. have had moderate success following not 100%.

it work values not others, return blanks , change values capitalization format, in other words if value 'test' display 'test'.

select substring(columnname, charindex('(', len(columnname)), charindex(')', columnname) - charindex('(',columnname)) input tablename 

update there 1 set of parentheses ()

this work provided have single occurence of ( , ):

select      substring(columnname,                charindex('(', columnname)+1,                charindex(')', columnname) - charindex('(', columnname)-1) tablename 

if have values not have (...) content, add clause:

where    charindex('(', columnname) > 0 ,           charindex(')', columnname) > charindex('(', columnname) 

Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -