我有一个删除任何非字母数字字符的函数,以及一个对EMIR表执行多次更新的存储过程。我的问题是,如何编写更新语句来调用函数RemoveNonAlphaNumericCharacters并更新字段'Underlying_Security_Name'
USE EMIR
GO
ALTER FUNCTION [dbo].[RemoveNonAlphaNumericCharacters]
(
-- Add the parameters for the function here
@String NVARCHAR(100)
)
RETURNS nvarchar(100)
AS
BEGIN
DECLARE @Keep_Value AS NVARCHAR(50)
SET @Keep_Value = '%[^a-z0-9 ]%'
WHILE PATINDEX(@Keep_Value, @String) > 0
BEGIN
SET @String = STUFF(@String, PATINDEX(@Keep_Value, @String), 1, '')
END
RETURN @String
END
GO
答案 0 :(得分:2)
你可以这样做。
UPDATE EMIR.table_name
SET Underlying_Security_Name = dbo.RemoveNonAlphaNumericCharacters(Underlying_Security_Name);