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 |
zgall1
Starting Member
9 Posts |
Posted - 2014-07-09 : 10:00:00
|
I have 1000 SQL rows that contain a column with data type LONGTEXT. Each of these columns contains an incorrect phone number somewhere within the column. I have tried the code below to update the phone number. UPDATE table SET text = replace('514-921-2738', '514-921-2738', '514-234-0315')However, instead of simply replacing the first phone number - 514-921-2738 - with the second phone number - 514-234-0315, it replaces the entire text block with the second phone number. In other words, all that remains after I run the code is the phone number. Clearly, I am not fully understanding how to use the REPLACE function but after looking at the online documentation, I don't see what I am doing wrong. Any thoughts? |
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2014-07-09 : 10:11:47
|
quote: Originally posted by zgall1 I have 1000 SQL rows that contain a column with data type LONGTEXT. Each of these columns contains an incorrect phone number somewhere within the column. I have tried the code below to update the phone number. UPDATE table SET text = replace(text, '514-921-2738', '514-234-0315')However, instead of simply replacing the first phone number - 514-921-2738 - with the second phone number - 514-234-0315, it replaces the entire text block with the second phone number. In other words, all that remains after I run the code is the phone number. Clearly, I am not fully understanding how to use the REPLACE function but after looking at the online documentation, I don't see what I am doing wrong. Any thoughts?
Too old to Rock'n'Roll too young to die. |
|
|
|
|
|
|
|