日期:2014-05-17 浏览次数:20567 次
declare @x varchar(50)
select @x='12345/43212/43453'
select replace(substring(@x,1,len(@x)-charindex('/',reverse(@x))),'/','-') 'x'
/*
x
------------------------
12345-43212
(1 row(s) affected)
*/
DECLARE @a VARCHAR(128)
SET @a='12345/43212/43453/43212//43212//43212//43212/43453'
SELECT REPLACE(SUBSTRING(@a,1,LEN(@a)-PATINDEX('%/%',REVERSE(@a))),'/','-')
/*
----------------------------------------------------------------------------------------------------------------
12345-43212-43453-43212--43212--43212--43212
*/
declare @d nvarchar(20)
set @d = '12345/43212/43453'
--select charindex('/',reverse(@d))
select replace(left(@d,len(@d) - charindex('/',reverse(@d))),'/','-')