How to remove first and last character of a string in SQL Server

Posted by SheoNarayan under Sql Server category on | Views : 62555
Use following code

SET @mykeyword = Substring(@mykeyword, 2, LEN(@mykeyword) - 2)

Lets say, your @mykeyword has "%sheo%", it will return "sheo".

To remove only last character from the string use following code

SET @keyword = Left(@keyword, Len(@keyword)-1)

Comments or Responses

Posted by: Sai on: 12/15/2008 Level:Starter | Status: [Member]
hi suryanarayana how u doing nice to read ur works
Posted by: Amatya on: 8/6/2015 Level:Starter | Status: [Member] | Points: 10
Good sir.. we can also use mid() function

Login to post response