动态 SQL--嵌套的 Replace() 函数

Dynamic SQL--Nested Replace() Function

我想替换 item_desc 中的特殊字符。此数据正在转换为 EDI,我在描述中没有 ~*

下面的代码行得通吗?我有双勾号,因为它是动态的 SQL。

replace(replace(sd.item_desc,''*'',''''),
    sd.item_desc,''~'','''') item_desc

不,它不会起作用。试试这个:

replace(replace(sd.item_desc, ''*'', ''''), ''~'', '''') item_desc

replace的第一个参数是一个字符串,你知道的,所以你需要在外层replace中提供字符串,这就是内层replace返回的字符串。