使用 VARCHAR(2) 4000 字节值更新列

UPDATE column with VARCHAR(2) 4000 byte value

我想更新一个 table,其中包含列中的复杂条目和列中的子句,而不影响其他值。

想要将 #Rule number=0# 更新为 #Rule number=1# 但不影响列中的其他值。这可能吗?

你在找replace()吗?如果 dynamic_attributes 是一个字符串:

update t
    set dynamic_attributes = replace(dynamic_attributes,
                                     '#Rule number=0#',
                                     '#Rule number=1#'
                                     )
    where dynamic_attributes like '%#Rule number=0#%';

注意:字符串可能不是存储此类列表的最佳方式。您应该考虑一个 table 每个 customer_id 一行和动态属性。

这里是:

UPDATE A 
SET A.dynamic_attributes = REPLACE(A.dynamic_attributes,'#Rule number=0#','#Rule number=1#')  
FROM yourtable AS A  
WHERE A.dynamic_attributes LIKE '%#Rule number=0#%'