日期:2014-05-18 浏览次数:20545 次
select reverse(left(reverse(a),charindex('-',reverse(a))-1)) from tb
------解决方案--------------------
create table tb(a varchar(20)) insert into tb values('1A00-DA001-0550') insert into tb values('1B001-DA002-0558') select reverse(left(reverse(a),charindex('-',reverse(a))-1)) from tb drop table tb /* -------------------- 0550 0558 (所影响的行数为 2 行) */
------解决方案--------------------
SELECT REVERSE(STUFF(REVERSE(A),CHARINDEX('-',REVERSE(A)),LEN(A),''))