日期:2014-05-18 浏览次数:20528 次
---测试数据---
if object_id('[tb]') is not null drop table [tb]
go
create table [tb]([col] varchar(28))
insert [tb]
select 'CCCIL-云南-法务-法务' union all
select 'CCCIL-云南-需求满足-基建工程' union all
select 'CCCIL-云南-总经办-总经办' union all
select 'CCCIL-云南-法务'
---查询---
select
col=left(col,len(col)-charindex('-',reverse(col)))
from
tb
---结果---
col
----------------------------
CCCIL-云南-法务
CCCIL-云南-需求满足
CCCIL-云南-总经办
CCCIL-云南
(4 行受影响)
------解决方案--------------------
如需要阅读该回复,请登录或注册CSDN!