SQL中自己创建函数 分割字符串(2)
来源:ddvip.com 时间:2008-11-20 16:13:00
WHILE @temp_i<@i
BEGIN
select @onlineornot = online from wwchat_user where epnum=dbo.getstrofindex(@str,',',@temp_i)
IF (@onlineornot=1)
begin
select @str_return =dbo.getstrofindex(@str,',',@temp_i)
select @findepnumok = 1 --找到epnum后置为1
BREAK
end
ELSE
begin
select @temp_i = @temp_i + 1
select @findepnumok = 0 --找不到epnum后置为1
end
END
if @findepnumok = 0
begin
SELECT @str_return = '00000000'
end
end
return @str_return
end
GO
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO
--getstrcount 输入一个没有分割的字符串,以及分割符
--返回数组的个数
CREATE function getstrcount (@str varchar(8000),@splitstr varchar(100))
--returns varchar(8000)
returns int
as
begin
declare @int_return int
declare @start int
declare @next int
declare @location int
select @next = 0
select @location = 1
if len(@str)<len(@splitstr)
select @int_return =0
if charindex(@splitstr,@str) = 0
select @int_return =0
while (@location<>0)
begin
select @start = @location + 1
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
编程经验点滴 动态SQL的拼接技巧
做设计还是做产品
面向对象的XHTML与CSS编程
VS 2008的性能改进
FSO读取BMP,JPG,PNG,GIF图像文件信息的函数
10分钟学会Google Map API (二)
利用XMLHTTP无刷新自动实时更新数据
DNS优化的原理和方法
![](https://img.aspxhome.com/file/20230519/1684460150434038s.jpg)
Mootools 1.2教程(9)——输入过滤第二部分(字符串)
asp动态页面生成html页面
闲谈CSS3动画
![](https://img.aspxhome.com/file/UploadPic/20105/7/t1ztvzxxhdxxxxxxxx-226-58-35s.png)
数字人组件反写[asp组件开发实例5]
![](https://img.aspxhome.com/file/UploadPic/20093/9/20093918286639s.gif)