假设你的字符串为@s
while patindex('%[^'^0-9,^a-z,^A-Z,^ ]%',@s)>0
stuff(@s,patindex('%[^'^0-9,^a-z,^A-Z,^ ]%',@s),1,'')
while patindex('%[^'^0-9,^a-z,^A-Z,^ ]%',@s)>0
stuff(@s,patindex('%[^'^0-9,^a-z,^A-Z,^ ]%',@s),1,'')
returns varchar(8000)
as
begin
while patindex('%[^a-zA-Z^0-9^ ^'']%',@str)>0
begin
set @str=stuff(@str,patindex('%[^a-zA-Z^0-9^ ^'']%',@str),1,'')
end return @str
end
go--调用
select dbo.f_replace('2dg6<;L,')/*
2dg6L(所影响的行数为 1 行)
*/
returns varchar(8000)
as
begin
while patindex('%[^a-zA-Z^0-9^ ^'']%',@str)>0
begin
set @str=stuff(@str,patindex('%[^a-zA-Z^0-9^ ^'']%',@str),1,'')
end return @str
end
go--调用
select dbo.f_replace('2dg6<;L,?')/*
2dg6L(所影响的行数为 1 行)
*/
declare @s varchar(8000),@s1 varchar(8000)
set @s=' 0(az*Jah.adf8UU'while patindex('%[^''^0-9,^a-z,^A-Z,^ ]%',@s)>0
set @s=stuff(@s,patindex('%[^''^0-9,^a-z,^A-Z,^ ]%',@s),1,'')select @s