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 |
|
jatrix32
Starting Member
49 Posts |
Posted - 2010-08-31 : 12:05:58
|
| I have a category that has users phone numbers as so: 333-333-3333I want to run an update query so all those phone number are converted to read: 3333333333I am new to SQL, like just started today. How do I go about doing this?And, what is a good SQL resource to go to for learning it? |
|
|
Transact Charlie
Master Smack Fu Yak Hacker
3451 Posts |
Posted - 2010-08-31 : 12:08:03
|
Hi jatrix.Best resource I ever found was this site!As long as you ask sensible questions you'll do fine.Also -- the inbuilt help for sql server is really good. Just press F1 in management studioTo replace - in a string use REPLACEExampleDECLARE @foo VARCHAR(255)SET @foo = '123-123-3333'SELECT REPLACE(@foo, '-', '') Charlie===============================================================Msg 3903, Level 16, State 1, Line 1736The ROLLBACK TRANSACTION request has no corresponding BEGIN TRANSACTION |
 |
|
|
jatrix32
Starting Member
49 Posts |
Posted - 2010-08-31 : 12:10:59
|
| Thanks Charlie, I am really new to this. I am not sure what you mean with the code you entered. I am the definition of an SQL noob. |
 |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2010-08-31 : 12:23:51
|
If you want to UPDATE your table with phone numbers without dashes:update your_tableset your_phone_column = replace(your_phone_column,'-','')where your_phone_column like '%-%'If you want to SELECT the data without making changes in the table:select replace(your_phone_column,'-','') as your_phone_columnfrom your_table No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
jatrix32
Starting Member
49 Posts |
Posted - 2010-08-31 : 12:34:55
|
| THANK YOU THANK YOU THANK YOU!!!!!!!!That worked!!!And I am going to use the resources that where suggested above to learn SQL. |
 |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2010-08-31 : 12:42:34
|
welcome  No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
|
|
|
|
|