I have a following string
90-PMR-450
90-PMRA-340
I want to get part 3 of string. example 450
or 340
.
plese help me. thanks
declare @T table
(
Value varchar(15)
)
insert into @T values
('90-PMR-450'),
('90-PMRA-340')
select stuff(Value, 1, 1+len(Value)-charindex('-', reverse(Value)), '')
from @t
DECLARE @x TABLE(v VARCHAR(32));
INSERT @x SELECT '90-PMR-450'
UNION ALL SELECT '90-PMRA-340';
SELECT Part3 = PARSENAME(REPLACE(v, '-', '.'), 1) FROM @x;
i think you will find this user defined function to split the string helpful:
http://www.codeproject.com/Articles/7938/SQL-User-Defined-Function-to-Parse-a-Delimited-Str
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.