ASPForums.Net RSS Feedhttp://www.aspforums.net/Handlers/RSS.ashxLatest additions to the content that appears on ASPForums.Net(c) 2019 www.aspforums.com. All rights reserved.Replace specific character from First and Last position of column value in SQL Server<p>Hey <a class="username" rel="PRA"> PRA</a>,</p> <p>Please refer below query.</p> <p><span style="text-decoration: underline;"><strong>SQL</strong></span></p> <pre class="brush: sql">DECLARE @INFO AS TABLE (Id INT, NAME VARCHAR(15)) INSERT INTO @INFO VALUES (1,&#39;Orange&#39;) INSERT INTO @INFO VALUES (2,&#39;Onion&#39;) INSERT INTO @INFO VALUES (3,&#39;Potatoes&#39;) INSERT INTO @INFO VALUES (4,&#39;Melon&#39;) SELECT Id,CASE WHEN name LIKE &#39;o%&#39; THEN SUBSTRING(name, 2, LEN(name)-1) WHEN name LIKE &#39;%o&#39; THEN LEFT(name, LEN(name)-1) ELSE name END Name FROM @INFO</pre> <p><span style="text-decoration: underline;"><strong>Output</strong></span></p> <table border="1"> <tbody> <tr> <td><strong>Id</strong></td> <td><strong>Name</strong></td> </tr> <tr> <td>1</td> <td>range</td> </tr> <tr> <td>2</td> <td>nion</td> </tr> <tr> <td>3</td> <td>Potatoes</td> </tr> <tr> <td>4</td> <td>Melon</td> </tr> </tbody> </table>https://www.aspforums.net:443/Threads/610390/Replace-specific-character-from-First-and-Last-position-of-column-value-in-SQL-Server/https://www.aspforums.net:443/Threads/610390/Replace-specific-character-from-First-and-Last-position-of-column-value-in-SQL-Server/Fri, 07 Dec 2018 03:18:47 GMT