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.
| Author |
Topic |
|
jetcityaaron
Starting Member
4 Posts |
Posted - 2011-10-05 : 18:17:50
|
| I'm new to SQL and I need help with a very basic query to remove punctuation from one of our database tables.Basically, we have a table called PATIENTS and in this table there is a field called LAST NAME where at the end of every patients last name there is a *I need to remove the * for 5000+ last names and I want to write a query to do this. I think I'm close but the query I'm writing is isn't working. This is what I have....Select * from PATIENT where LAST NAME like '*'I thought that query would remove all the punctuation with the * in that field but it didn't. What am I doing wrong? |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
|
|
jetcityaaron
Starting Member
4 Posts |
Posted - 2011-10-05 : 18:36:07
|
| Awesome! That worked.Thanks Tara :) |
 |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
|
|
jetcityaaron
Starting Member
4 Posts |
Posted - 2011-10-10 : 17:36:28
|
| The query worked pretty good but I still have a couple hundred last names with a *It appears the query remove all the *'s where the * was at the end of the last name.In this case I have *'s right in the middle of the last name How would I remove the * from a last name that is spelled SM*TH ? |
 |
|
|
jassi.singh
Posting Yak Master
122 Posts |
Posted - 2011-10-11 : 01:12:11
|
| update PATIENTSset [last name] = REPLACE([last name], '*', '')where [last name] like '%*%'Please mark answer as accepted if it helped you.Thanks,Jassi Singh |
 |
|
|
Cindyaz
Yak Posting Veteran
73 Posts |
Posted - 2011-10-11 : 04:18:23
|
| Use the same query posted by Tara Kizer without the where clause. This will replace all * with '' from the last name. |
 |
|
|
jetcityaaron
Starting Member
4 Posts |
Posted - 2011-10-11 : 19:25:14
|
| Ahhh - just one % was all I needed.I thought I tried that earlier but I just copied\pasted that in and it worked.Thanks for the replies Jassi, Tara and Cindyaz. |
 |
|
|
|
|
|