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

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 remove commas
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

esthera
Flowing Fount of Yak Knowledge

1410 Posts

Posted - 03/08/2007 :  12:23:39  Show Profile  Reply with Quote
how can i take a field and remove all commas from teh field

so select name,address from customer but if there is a comma in address it should remove it?

snSQL
Flowing Fount of Yak Knowledge

USA
1837 Posts

Posted - 03/08/2007 :  12:39:06  Show Profile  Reply with Quote
Use the replace function

SELECT [Name], replace([Address], ',', '') AS [Address]
FROM table1

Edited by - snSQL on 03/08/2007 12:39:31
Go to Top of Page

Lamprey
Flowing Fount of Yak Knowledge

4614 Posts

Posted - 03/08/2007 :  12:40:44  Show Profile  Reply with Quote
SELECT name , REPLACE(address, ',', '') AS address
FROM Customer


-Ryan

EDIT: Dang, too slow. :)

Edited by - Lamprey on 03/08/2007 12:41:21
Go to Top of Page

esthera
Flowing Fount of Yak Knowledge

1410 Posts

Posted - 03/08/2007 :  12:41:57  Show Profile  Reply with Quote
great -- didn't know there was a replace funtion
can 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?
Go to Top of Page

snSQL
Flowing Fount of Yak Knowledge

USA
1837 Posts

Posted - 03/08/2007 :  12:57:46  Show Profile  Reply with Quote
Just call it multiple times

SELECT [Name], replace(replace([Address], ',', ''), '#', '') AS [Address]
FROM table1

Go to Top of Page
  Previous Topic Topic Next Topic  
 Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.02 seconds. Powered By: Snitz Forums 2000