I need to select a substring found between (). The starting and ending positions will vary, as well as the length of the substring. I had moderate success with the following, but not 100%.
It will work for some values, but not for others, it returns spaces and also changes the format of capitalization of values, in other words, if the value "TEST" is displayed as "Test".
SELECT SUBSTRING(columnName, CHARINDEX('(', LEN(columnName)), CHARINDEX(')', columnName) - CHARINDEX('(',columnName)) AS INPUT FROM tableName
Update There is only 1 set of parentheses ()
substring sql sql-server select
Reene
source share