我有数百万个与数据库中文件路径相关的字符串;
由于使用了第三方程序,这些路径已嵌套如下:
C:\files\thirdparty\thirdparty\thirdparty\thirdparty\thirdparty\thirdparty\unique_bit_here\
我想更新条目,以使
thirdparty\thirdparty\etc
变为\thirdparty
。我已经试过这段代码:
UPDATE table
SET Field = REPLACE(Field, 'tables\thirdparty\%thirdparty\%\', 'tables\thirdparty\')
最佳答案
WHILE EXISTS (SELECT * FROM table WHERE Field LIKE '%\thirdparty\thirdparty\%')
BEGIN
UPDATE table SET Field = REPLACE(Field, '\thirdparty\thirdparty\', '\thirdparty\')
END