你的 @pid根本没有用到 ,如果得的函数是完整的,建议你改成下面的,你的处理太麻烦了。下面的函数不知道是否是你的意思 。alter FUNCTION GetFormateVitae (@notes varchar(8000)) RETURNS varchar(8000) AS BEGIN
declare @startTag char(4)set @startTag = '<br>'while charindex(@startTag, @notes)>0 begin set @notes=REPLACE(@notes,@startTag,'')endreturn rtrim(@notes) END SQL查询分析器如何不能设置断点
CREATE FUNCTION GetFormateVitae (@notes varchar(8000)) RETURNS varchar(8000) AS BEGIN
/* * Do special format job for [tb_psn_vitae].[notes] */-- declare declare @startTag varchar(50) declare @endTag varchar(50) declare @stuff varchar(1) declare @divisor intdeclare @content varchar (8000) declare @part varchar(8000) declare @startIndex int declare @pid varchar(18) declare @endIndex int declare @remainder int declare @notesFormated varchar(8000)-- set constant set @startTag = '<br>' set @endTag = '<br>' set @notesFormated = '' set @divisor = 100 set @stuff = ' ' -- clear @notesFormated set @notesFormated = '' -- add tag set @notes = @startTag + @notes + @endTag
while charindex(@startTag, @notes)>0 begin -- get startIndex & endIndex set @startIndex = charindex(@startTag, @notes) /* get proper index */ set @endIndex = charindex(@endTag, @notes, @startIndex + 1) -- if not found then break if (@startIndex is null) or (@endIndex is null) or (@startIndex >= @endIndex) break -- process normal text if @startIndex != 1 begin set @part = left(@notes, @startIndex - 1) set @remainder = len(@part) % @divisor
-- add space to the end of section while @divisor - @remainder > 0 begin set @part = @part + @stuff set @remainder = @remainder + 1 end -- just add it to notesFormated set @notesFormated = @notesFormated + @part -- update notes set @notes = right(@notes, len(@notes) - @startIndex + 1) continue end -- process section set @part = substring(@notes, @startIndex + len(@startTag), @endIndex - @startIndex - len(@startTag)) set @remainder = len(@part) % @divisor -- add space to the end of section while @divisor - @remainder > 0 begin set @part = @part + @stuff set @remainder = @remainder + 1 end -- update notesFormated & notes /* set @notesFormated = @notesFormated + @startTag + @part + @endTag set @notes = right(@notes, len(@notes) - len(@part) - len(@startTag) - len(@endTag)) */ set @notesFormated = @notesFormated + @part set @notes = right(@notes, len(@notes) - len(@part) - len(@startTag)) end -- update notes set @notesFormated = rtrim(@notesFormated) set @content=@notesFormated
RETURNS varchar(8000) AS
BEGIN
declare @startTag char(4)set @startTag = '<br>'while charindex(@startTag, @notes)>0
begin
set @notes=REPLACE(@notes,@startTag,'')endreturn rtrim(@notes)
END
SQL查询分析器如何不能设置断点
--左连的对象浏览器(没有的话按F8)
--对象项中
--右键调试的存储过程
--调试
--输入参数(必须输入所有的参数,包括默认值/输出参数
--点击执行
--出现一个浮动工具条
--上面有单步执行,断点设置等按F11是单步执行.如果要运行到指定行,只需要将光标移动到指定的行,再按Ctrl+F10
RETURNS varchar(8000) AS
BEGIN
/*
* Do special format job for [tb_psn_vitae].[notes]
*/-- declare
declare @startTag varchar(50)
declare @endTag varchar(50)
declare @stuff varchar(1)
declare @divisor intdeclare @content varchar (8000)
declare @part varchar(8000)
declare @startIndex int
declare @pid varchar(18)
declare @endIndex int
declare @remainder int
declare @notesFormated varchar(8000)-- set constant
set @startTag = '<br>'
set @endTag = '<br>'
set @notesFormated = ''
set @divisor = 100
set @stuff = ' '
-- clear @notesFormated
set @notesFormated = ''
-- add tag
set @notes = @startTag + @notes + @endTag
while charindex(@startTag, @notes)>0
begin
-- get startIndex & endIndex
set @startIndex = charindex(@startTag, @notes)
/* get proper index */
set @endIndex = charindex(@endTag, @notes, @startIndex + 1) -- if not found then break
if (@startIndex is null) or (@endIndex is null) or (@startIndex >= @endIndex)
break -- process normal text
if @startIndex != 1
begin
set @part = left(@notes, @startIndex - 1)
set @remainder = len(@part) % @divisor
-- add space to the end of section
while @divisor - @remainder > 0
begin
set @part = @part + @stuff
set @remainder = @remainder + 1
end
-- just add it to notesFormated
set @notesFormated = @notesFormated + @part
-- update notes
set @notes = right(@notes, len(@notes) - @startIndex + 1)
continue
end -- process section
set @part = substring(@notes, @startIndex + len(@startTag), @endIndex - @startIndex - len(@startTag))
set @remainder = len(@part) % @divisor -- add space to the end of section
while @divisor - @remainder > 0
begin
set @part = @part + @stuff
set @remainder = @remainder + 1
end -- update notesFormated & notes
/*
set @notesFormated = @notesFormated + @startTag + @part + @endTag
set @notes = right(@notes, len(@notes) - len(@part) - len(@startTag) - len(@endTag))
*/
set @notesFormated = @notesFormated + @part
set @notes = right(@notes, len(@notes) - len(@part) - len(@startTag)) end -- update notes
set @notesFormated = rtrim(@notesFormated) set @content=@notesFormated
return rtrim(@content)
END我试过了 我这样写没有什么问题 但是比较慢 哪位达人能帮忙看下 优化下感谢