Sample string: 'DotNetMirror,'
Now we will remove , from the string.
Get Last Char in string:
Declare @STRING varchar(100)
set @STRING='DotNetMirror,'
select RIGHT(@String, 1)
Remove the last char(comma) in string :
IF(LEN(@String)> 0 AND RIGHT(@String, 1) = ',')
BEGIN
select substring(@String, 1, (len(@String) - 1)) --or
SET @String = LEFT(@String, LEN(@String) - 1)
END
select @String
1 Comments:
DECLARE @STRING varchar(100)
SET @STRING='DotNetMirror,'
SELECT CASE WHEN LEN(@STRING)>1 THEN SUBSTRING(@STRING,1,charindex(RIGHT(@STRING,1),@STRING)-1) END
Post a Comment