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 2000 Forums
 Transact-SQL (2000)
 string functions

Author  Topic 

cray
Starting Member

9 Posts

Posted - 2005-11-01 : 12:57:31
I just use SQL for queries & some stored procedures. Not a developer.
Question: How can I use replace more than once to eliminate characters? I want to eliminate all " ", "." in a lastname field. Right now that field has things like: 'DOE JR.' or 'ADAMS, SR.'
I want to eliminate commas and spaces. I tried below with a % but didn't work.

Select replace(lastname,', JR.','JR') [and replace(lastname,', SR.','SR')]
From tablename

sachinsamuel
Constraint Violating Yak Guru

383 Posts

Posted - 2005-11-01 : 13:04:11

Try This out


Select replace(replace(lastname,', JR.','JR'),', SR.','SR')
From tablename


regards
Sachin
Go to Top of Page

nr
SQLTeam MVY

12543 Posts

Posted - 2005-11-01 : 13:04:22
replace(replace(fld,',',''),' ','')


==========================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page
   

- Advertisement -