SQL中自己创建函数 分割字符串

来源:ddvip.com 时间:2008-11-20 16:13:00 

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[getEPnum]') and xtype in (N'FN', N'IF', N'TF'))

  drop function [dbo].[getEPnum]

  GO

  if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[getstrcount]') and xtype in (N'FN', N'IF', N'TF'))

  drop function [dbo].[getstrcount]

  GO

  if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[getstrofindex]') and xtype in (N'FN', N'IF', N'TF'))

  drop function [dbo].[getstrofindex]

  GO

  SET QUOTED_IDENTIFIER ON

  GO

  SET ANSI_NULLS ON

  GO

  --- 这个函数直接调用了另外的两个函数,可以先阅读下面提到的两个函数

  CREATE  function getEPnum (@str varchar(8000))

  returns varchar(8000)

  as

  begin

  declare @str_return varchar(8000) 

  declare @i int

  declare @temp_i int

  declare @onlineornot int

  declare @findepnumok int

  -- 用来取得一个epnum,

  -- 规则:首先从chatid中取,如果有在线得,则取得最前面得在线得返回

  --    如果全部不在线,则返回 ‘00000000’

   select @findepnumok = 0

  select @temp_i = 0

  IF len(@str)<=0

  begin

  SELECT @str_return = '00000000'

  end

  else

  begin

  select @i = dbo.getstrcount(@str,',')

标签:
0
投稿

猜你喜欢

  • 在asp中使用存储过程

    2008-02-26 12:17:00
  • 交互设计的方法

    2010-08-18 12:32:00
  • innerHTML,outerHTML,innerText,outerText用法

    2008-02-15 12:22:00
  • 有故事的网页设计——Flash网站奇妙之旅

    2011-01-20 19:58:00
  • oracle 触发器 学习笔记

    2009-05-24 19:57:00
  • ORACLE数据库应用开发常见问题及排除

    2010-07-26 13:17:00
  • 怎样生成utf-8编码的html文件

    2009-03-11 19:34:00
  • 定位后无法选择容器内容解决方案

    2008-07-28 13:14:00
  • SQL Server重温 事务

    2012-08-21 10:48:15
  • 请问[\\u4E00-\\u9FA5]是什么正则表达式码

    2009-07-10 13:10:00
  • XHTML与HTML之间的7个区别

    2009-05-20 10:13:00
  • SQL 语句中的通配符

    2007-10-11 18:03:00
  • 比较SQL Server约束和DML触发器

    2008-12-24 15:54:00
  • 如何取得所有的Session变量

    2008-06-08 13:59:00
  • CSS压缩:技巧与工具

    2009-12-11 18:26:00
  • ASP中利用OWC控件实现图表功能详解

    2010-05-27 12:26:00
  • 正则表达式不匹配某个字符串

    2010-03-02 22:08:00
  • 长文章自动分页asp实例-支持HTML

    2007-10-10 21:29:00
  • SQL Server 2005中数据库镜像的四个问题

    2009-02-19 16:48:00
  • IE的有条件注释详解(附实例代码)

    2009-03-31 13:01:00
  • asp之家 网络编程 m.aspxhome.com