Site Sponsored By: SQLDSC - SQL Server Desired State Configuration
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.
how can i take a field and remove all commas from teh fieldso select name,address from customer but if there is a comma in address it should remove it?
snSQL
Master Smack Fu Yak Hacker
1837 Posts
Posted - 2007-03-08 : 12:39:06
Use the replace function
SELECT [Name], replace([Address], ',', '') AS [Address]FROM table1
Lamprey
Master Smack Fu Yak Hacker
4614 Posts
Posted - 2007-03-08 : 12:40:44
[code]SELECT name , REPLACE(address, ',', '') AS addressFROM Customer[/code]-RyanEDIT: Dang, too slow. :)
esthera
Master Smack Fu Yak Hacker
1410 Posts
Posted - 2007-03-08 : 12:41:57
great -- didn't know there was a replace funtioncan i make a strip function to remove commas and # and anything else i see as an issue and then just use that function? would this work? how?
snSQL
Master Smack Fu Yak Hacker
1837 Posts
Posted - 2007-03-08 : 12:57:46
Just call it multiple times
SELECT [Name], replace(replace([Address], ',', ''), '#', '') AS [Address]FROM table1