Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Remove special characters

Author  Topic 

sqlpal2007
Posting Yak Master

200 Posts

Posted - 2009-11-18 : 07:31:22
Hello All,

How woudl I remove special characters and spaces from a string? I have to update a column by removing the spaces and special characters like -, %, #, _ etc.

Example - Part# column

RE34-Y 2 should be RE34Y2

Any help would be appreciated.

Thanks,
-S

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2009-11-18 : 07:35:19
Use multiple replaces

update table
set col=replace(replace(replace(col,' ',''),'-',''),'#')

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

sqlpal2007
Posting Yak Master

200 Posts

Posted - 2009-11-18 : 07:44:58
Thanks Madhivanan.

That is what I have been using. Is there any alternate way to do it?

Thanks,
-S
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2009-11-18 : 07:47:14
quote:
Originally posted by sqlpal2007

Thanks Madhivanan.

That is what I have been using. Is there any alternate way to do it?

Thanks,
-S


Refer
http://sqlblogcasts.com/blogs/madhivanan/archive/2009/05/11/removing-unwanted-characters.aspx

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -