Remove special characters (-, _,) from string in SQL SERVER - Free Asp.Net,MVC,AngularJs,Jquery,Javascript,Sql Server,WCF,Entity framework snippets and tutorial

Remove special characters (-, _,) from string in SQL SERVER

In this article I am going to explain how to remove the special characters like coma (,), hyphen (-), underscore (_) from string using Sql server.



Implementation:

To remove the special characters from string I am using the REPLACE function of sql server.
I have created a table and insert some dummy record into it.


Remove special characters (-, _,) from string in SQL SERVER


I want to remove the.,_,- from student name and username. Here is the SQL  query to get student and username without special characters.

SELECT REPLACE(replace(StName,'.',' '),'_',' ') AS [Student Name],
replace(replace(replace(StUsername,'_',' '),'-',' '),'.',' ') as [username]
FROM Tb_Student

OUTPUT:


Remove special characters (-, _,) from string in SQL SERVER

What do you think about this article?

If you found this article useful, please share and follow on Facebook, Twitter, Google Plus and other social media websites. To get free updates subscribe to newsletter. Please put your thoughts and feedback in comments section.

Share this

Share on FacebookTweet on TwitterPlus on Google+


EmoticonEmoticon