6
votes

Comment trouver sous-chaîne et remplacez-le?

J'ai les lignes suivantes:

Name               Url
name1              http://foo.com/this/that
name6              http://that.net/hello
name2              http://foo.com/hello/world
name3              http://foo.com/world/hello
name4              http://hello.com/this/that


0 commentaires

5 Réponses :


6
votes
UPDATE <table name> SET Url = REPLACE (Url, "foo.com" , "hello.com")

0 commentaires

5
votes

Jetez un oeil à la fonction Remplacer (): http: // msdn. microsoft.com/en-us/library/ms186862.aspx . Vous devriez être capable d'utiliser cela dans une instruction de mise à jour pour obtenir le résultat souhaité.


0 commentaires

4
votes

Consultez le Remplacer fonction:

update table set url = replace(url, 'foo.com', 'hello.com')


0 commentaires

3
votes
UPDATE table
SET Url = REPLACE(url, 'foo.com', 'hello.com')

0 commentaires

1
votes
UPDATE table
SET Url = REPLACE(url, 'http://foo.com/', 'http://hello.com/')
it's safer!!

0 commentaires