2012-06-06 41 views
0

我正在更新特定列的許多字符串中的單詞。在Sql中更新字符串

例如;

Update Column A = 'This is a line of text.' 
To 'This is a string of text.' 

其中列A可能在DB中出現多次。顯然我只能說;

Update 
    TABLE 
Set 
    A = 'This is a string of text.' 
Where 
    A = 'This is a line of text.' 

但我很想好一種更好的方式做,也許使用正則表達式?某事沿着;

Update 
    TABLE 
Set 
    A = [First Part of A] + 'string' + [Second Part of A] 
Where 
    A = 'This is a line of text.' 

回答

2

使用此:

A = REPLACE(A, 'string', 'line') WHERE A LIKE '%line%' 
+0

太明顯的答案。謝了哥們。 – windowskm