截取字符串

1    800022521     AAA(1256)(800022521)
2    100876747     BBB(100876747)
WITH a1 (COL1,COL2) AS
(
SELECT 1,'AAA(1256)(800022521)' UNION all
SELECT 2,'BBB(100876747)'
)
,a2 AS
(
SELECT COL1,REVERSE(COL2) COL2
FROM a1
)
SELECT COL1,REVERSE(STUFF(LEFT(COL2,CHARINDEX('(',COL2)-1),1,1,''))
FROM a2

 

posted @ 2015-02-28 14:22  emmy  阅读(168)  评论(0编辑  收藏  举报