如何查找子字符串并替换它?

Phi*_*own 6 sql t-sql sql-server

我有以下几行:

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
Run Code Online (Sandbox Code Playgroud)

我需要编写一个查询,将所有的改变foo.comhello.com.

有任何想法吗?

Coo*_*raw 6

UPDATE <table name> SET Url = REPLACE (Url, "foo.com" , "hello.com")
Run Code Online (Sandbox Code Playgroud)


DCN*_*YAM 5

看一下REPLACE()函数:http://msdn.microsoft.com/en-us/library/ms186862.aspx.您应该能够在UPDATE语句中使用它来实现所需的结果.