IF OBJECT_ID('DBO.GET_ZNSTR') IS NOT NULL
DROP FUNCTION DBO.GET_ZNSTR
GO
CREATE FUNCTION DBO.GET_ZNSTR(@S NVARCHAR(100))
RETURNS VARCHAR(100)
AS
BEGIN
WHILE PATINDEX('%[^吖-座]%',@S) > 0
SET @S = STUFF(@S,PATINDEX('%[^吖-座]%',@S),1,N'')
RETURN @S
END
GO
---------------------
测试语句:
SELECT DBO.GET_ZNSTR('123abc哈哈ACE呼呼')
结果如下: