当前位置:首页 > 网络编程 > 数据库 > SQL Server > SQL中自己创建函数 分割字符串

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

点击次数:24 次 发布日期:2008-11-21 22:42:31 作者:源代码网
源代码网推荐
以下为引用的内容:

源代码网整理以下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)
会员中心
网络编程
本站推荐
网络编程之精华