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 

标签:
0
投稿

猜你喜欢

  • 编程经验点滴 动态SQL的拼接技巧

    2012-11-30 20:03:58
  • 做设计还是做产品

    2009-06-11 13:01:00
  • 面向对象的XHTML与CSS编程

    2008-01-11 13:37:00
  • VS 2008的性能改进

    2007-10-07 21:42:00
  • FSO读取BMP,JPG,PNG,GIF图像文件信息的函数

    2007-08-04 09:56:00
  • 10分钟学会Google Map API (二)

    2009-06-07 18:14:00
  • 利用XMLHTTP无刷新自动实时更新数据

    2008-02-19 18:29:00
  • DNS优化的原理和方法

    2012-04-26 16:43:56
  • Mootools 1.2教程(9)——输入过滤第二部分(字符串)

    2008-12-01 12:25:00
  • asp动态页面生成html页面

    2008-10-24 09:03:00
  • 闲谈CSS3动画

    2010-05-07 12:34:00
  • 数字人组件反写[asp组件开发实例5]

    2009-06-09 13:23:00
  • 用正则替换所有URL

    2009-03-13 13:51:00
  • js表单检测数字

    2007-10-12 13:52:00
  • 显示/隐藏引出的CSS Bug

    2010-10-20 20:13:00
  • 基于SQL Server的C/S数据库应用系统

    2009-01-21 14:44:00
  • 网页设计细节不能丢

    2007-09-26 11:54:00
  • asp常用的SQL命令操作

    2007-09-29 12:21:00
  • PHP获取特殊时间戳的方法整理

    2023-05-25 00:47:36
  • 盲人站长深恶痛绝的onfocus=”this.blur()”

    2011-04-22 12:25:00
  • asp之家 网络编程 m.aspxhome.com