Pages

Showing posts with label Query for remove a character from a string. Show all posts
Showing posts with label Query for remove a character from a string. Show all posts

Tuesday, September 17, 2013

SQL Server Query for remove first / last character in a string

Hi now we can see how to remove first / last character in a string SQL Server.


Query for remove first char

Example

DECLARE @rollid NVARCHAR(MAX)
SET @rollid=',18,24,40,'
SELECT Substring(@rollid, 2, (len(@rollid))) as Rollno

Result
18,24,40,

Query for remove last character from string

Example

DECLARE @rollid NVARCHAR(MAX)
SET @rollid='18,24,40,'
SELECT Substring(@rollid, 1, (len(@rollid)-1)) as Rollno

Result
18,24,40