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
Post a Comment