Removing Last Character from any given String.

vishalneeraj-24503
Posted by vishalneeraj-24503 under Sql Server category on | Points: 40 | Views : 189
Below query will remove Last Character i.e. # from given string expression.
This works exactly same as LastIndexOf Method in Dot Net.
DECLARE @INPUT_VALUE AS VARCHAR(50);
SET @INPUT_VALUE = 'VISHAL#KUMER#NEERAJ#';
SELECT SUBSTRING(@INPUT_VALUE,1,LEN(@INPUT_VALUE)-1) AS 'REMOVE_LAST_CHARACTER';

You can convert above query into Function and this function will take 2 arguments as String expression and Deliminated Characters.
Output:-
VISHAL#KUMER#NEERAJ

Comments or Responses

Login to post response