Go homepage(回首页)
Upload pictures (上传图片)
Write articles (发文字帖)

The author:(作者)归海一刀
published in(发表于) 2014/2/1 0:14:58
sqlserver过滤字符串中的空格的自定义函数_[SQL,Server教程]

sqlserver过滤字符串中的空格的自定义函数_[SQL Server教程]

去掉字符串中的所有空格


CREATE Function f_trimstr(@str varchar(100))


returns varchar(100)


AS


begin


declare @i int
declare @s1 varchar(50)
declare @result varchar(100)
declare @len int


select @result = ''
select @str = ltrim(rtrim(@str))
select @len = len(@str)
select @i = 1


while @i<=@len
begin
select @s1 = substring(@str,@i,1)
if(@s1<>'')
begin
select @result = @result + @s1
end
select @i = @i + 1
end


return @result


end







If you have any requirements, please contact webmaster。(如果有什么要求,请联系站长)





QQ:154298438
QQ:417480759