我正在使用的SQL Server 2012中没有默认的拆分功能。
我想用/Folder1/Folder2/
分割字符串(例如:/
)。
/Folder1/
,则输出应为Folder1
,/Folder1/Folder2/
,则输出应为Folder2
,/Folder1/Folder2/Folder3/
,则输出应为Folder3
。答案 0 :(得分:1)
尝试一下:
declare @tbl table (path varchar(100));
insert into @tbl values
('/Folder1/'),
('/Folder1/Folder2/'),
('/Folder1/Folder2/Folder3/');
select *,
replace(substring(path, len(path) - charindex('/', reverse(path), 2) + 1, 1000), '/', '')
from @tbl