Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/sql/71.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/sql-server/22.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
函数删除SQL Server中的字符集_Sql_Sql Server - Fatal编程技术网

函数删除SQL Server中的字符集

函数删除SQL Server中的字符集,sql,sql-server,Sql,Sql Server,我有以下函数从给定字符串中删除字符集: ALTER function removalspchar(@Name varchar(30)) returns varchar(500) As Begin declare @sub char(1) while patindex('%[-:;&, ]%',@Name)>0 begin set @sub=substring(@Name,patindex('%[-:;&, ]%',@Name),1) set @Name = re

我有以下函数从给定字符串中删除字符集:

ALTER function removalspchar(@Name varchar(30))
returns varchar(500)
As 
Begin 
declare @sub char(1)

while patindex('%[-:;&, ]%',@Name)>0
begin 
 set @sub=substring(@Name,patindex('%[-:;&, ]%',@Name),1)
 set @Name = replace(@Name,@sub,'')
end

return @Name
End

select dbo.removalspchar('CORP - Sovereign & Public Finance')
但以下功能的输出是:CORPSovereignPublicFina,而不是CORPSovereignPublicFinance


有人能告诉我我做了什么不正确的事情,或者有更好的方法来解决这个问题。

也许,你应该增加param
(@Name varchar(30))
的长度,比如说
(@Name varchar(100))