当前位置: 代码迷 >> Sql Server >> 如何用T-SQL语句 取出 "\客厅\古典\pgkt-gd0375.jpg" 中的 客厅
  详细解决方案

如何用T-SQL语句 取出 "\客厅\古典\pgkt-gd0375.jpg" 中的 客厅

热度:189   发布时间:2016-04-27 18:42:46.0
怎么用T-SQL语句 取出 "\客厅\古典\pgkt-gd0375.jpg" 中的 客厅
怎么用T-SQL语句 取出 "\客厅\古典\pgkt-gd0375.jpg" 中第一个"\"和第二个"\"之间的 客厅

"\客厅\现代古典\pgkt-xg0194.jpg"中第一个"\"和第二个"\"之间的客厅 

谢谢阿

------解决方案--------------------
SQL code
create table tb(s varchar(100))insert into tb select '\客厅\现代古典\pgkt-xg0194.jpg'insert into tb select '撒法\厨房\现代古典\pgkt-xg0194.jpg'select substring(s,charindex('\',s)+1,charindex('\',s,charindex('\',s)+1)-charindex('\',s)-1)from tb
------解决方案--------------------
create table tb(s varchar(100))
insert into tb select '\客厅\现代古典\pgkt-xg0194.jpg'
insert into tb select '撒法\厨房\现代古典\pgkt-xg0194.jpg'
select substring(s,charindex('\',s)+1,charindex('\',s,charindex('\',s)+1)-charindex('\',s)-1)
from tb
  相关解决方案