ifexists(select*fromdbo.sysobjectswhereid=object_id(N[dbo].[getEPnum])andxtypein(NFN,NIF,NTF))
dropfunction[dbo].[getEPnum]
GO
ifexists(select*fromdbo.sysobjectswhereid=object_id(N[dbo].[getstrcount])andxtypein(NFN,NIF,NTF))
dropfunction[dbo].[getstrcount]
GO
ifexists(select*fromdbo.sysobjectswhereid=object_id(N[dbo].[getstrofindex])andxtypein(NFN,NIF,NTF))
dropfunction[dbo].[getstrofindex]
GO
SETQUOTED_IDENTIFIERON
GO
SETANSI_NULLSON
GO
---这个函数间接挪用了别的的两个函数,能够先浏览上面提到的两个函数
CREATEfunctiongetEPnum(@strvarchar(8000))
returnsvarchar(8000)
as
begin
declare@str_returnvarchar(8000)
declare@iint
declare@temp_iint
declare@onlineornotint
declare@findepnumokint
IFlen(@str)<=0
begin
SELECT@str_return=00000000
end
else
begin
select@i=dbo.getstrcount(@str,,)
WHILE@temp_i<@i
BEGIN
select@onlineornot=onlinefromwwchat_userwhereepnum=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
SETQUOTED_IDENTIFIEROFF
GO
SETANSI_NULLSON
GO
SETQUOTED_IDENTIFIERON
GO
SETANSI_NULLSON
GO
--getstrcount输出一个没有支解的字符串,和支解符
--前往数组的个数
CREATEfunctiongetstrcount(@strvarchar(8000),@splitstrvarchar(100))
--returnsvarchar(8000)
returnsint
as
begin
declare@int_returnint
declare@startint
declare@nextint
while(@location0)
begin
select@start=@location+1
select@location=charindex(@splitstr,@str,@start)
select@next=@next+1
select@int_return=@next
end
return@int_return
end
GO
SETQUOTED_IDENTIFIEROFF
GO
SETANSI_NULLSON
GO
SETQUOTED_IDENTIFIERON
GO
SETANSI_NULLSON
GO
--getstrofindex输出一个未支解的字符串,恬逸支解标记,恬逸要获得的字符地位
--前往制订地位的字符串
CREATEfunctiongetstrofindex(@strvarchar(8000),@splitstrvarchar(4),@indexint=0)
returnsvarchar(8000)
as
begin
declare@str_returnvarchar(8000)
declare@startint
declare@nextint
declare@locationint