如何替换本机编译模块中的函数 REPLACE()?

How to replace function REPLACE() in Natively-compiled module?

我将我的旧存储过程 (SQL Server 2016) 转换为本机编译的过程,并在一个地方收到:

SELECT @name = REPLACE(@inname, ':' + @new + ':', ':' + @old + ':')

Msg 10794, Level 16, State 93, Procedure usp_2, Line 101 [Batch Start Line 108]
The function 'replace' is not supported with natively compiled modules.

如何替换函数REPLACE()

典型的模式是使用普通的 TSQL 过程包装器和本地编译的子过程。 TSQL 包装器在调用本机编译的过程之前执行任何不受支持的操作,并在乐观并发异常的情况下处理重试。