在SQLSERVER中处理特殊字符以及空格。

--去除特殊字符,只留0-9,a-z,A-Z

declare @teststr varchar(100)

set @teststr='test #123^we'

while patindex('%[^0-9a-zA-Z]%',@teststr)>0

         SET @teststr=STUFF(@teststr, patindex('%[^0-9a-zA-Z]%',@teststr),1,'')

SELECT @teststr

----------------------------------------------------------------------------------------------------

test123we

(1 行受影响)
————————————————
版权声明:本文为CSDN博主「even0220」的原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/even0220/article/details/6021298

原文地址:https://www.cnblogs.com/footleg/p/12403241.html