Chrissy321 (4/18/2013)
Am I over complicating the string extraction? I want the text between the first and second occurrences of '.'DECLARE @paths TABLE(path varchar(50))
INSERT INTO @paths
SELECT '.ab.qwer.poi' UNION
SELECT '.1.qwerty.ab' UNION
SELECT '.1234567890.asd.a'
See if it will work for you:
SELECT
path, REVERSE(PARSENAME(REVERSE(path) + ' ', 2)), PARSENAME(path, 3)
-- " + ' '" is added to avoid "NULL" object names when there is nothing in front of the 1st dot.
FROM @paths
Both options in my query return the same values from your sample data.
Check which of them better fits the logic using to build the strings in the table.
_____________
Code for TallyGenerator