ITPub博客

首页 > 数据库 > SQL Server > SQL Server 检测字符串中是否有重复字符的函数

SQL Server 检测字符串中是否有重复字符的函数

原创 SQL Server 作者:Groundsel 时间:2009-01-01 14:22:29 0 删除 编辑

SQL Server 2000

检测字符串中是否有重复字符的函数

Create Function FN_DupChar
(@String Varchar(100))
Returns Bit
As
Begin
Declare @Temp Table(Chr Varchar(1))

Declare @i Int ,@j Int
Select @i = 1, @j = 0
While @i <= Len(@String)
Begin
Insert Into @Temp Select Substring(@String,@i,1)
Select @i = @i + 1
End

If Exists(Select 1 From @Temp Group By Chr Having Count(*) > 1)
Begin
Set @j = 1
End
Return @j

End

[@more@]

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/62592/viewspace-1015572/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论
  • 博文量
    13
  • 访问量
    45044