DotNetGnat
Programmer
Guys, i have a text field and inside the text field i have a portion that looks like:
<!--blah blah blah-->
i want to update that portion to
<!--DotNetGnat-->
i came up with the below stored procedure and it works fine...but takes a lot of time to complete...can you guys suggest anything else for better performance...
-DNG
<!--blah blah blah-->
i want to update that portion to
<!--DotNetGnat-->
i came up with the below stored procedure and it works fine...but takes a lot of time to complete...can you guys suggest anything else for better performance...
Code:
CREATE Procedure ResumeTextCleanup
@WBS1 varchar(30)='%'
,@DescCategory varchar(10)='%'
AS
Declare @startpos int
,@endpos int
,@ptr binary(16)
,@commentlen int
,@adjuststart int
Declare MyCursor CURSOR for
select WBS1, DescCategory from mytable
where WBS1 Like @WBS1
And DescCategory Like @DescCategory
AND PatIndex('%'+'<!--'+'%',Description)>0
open MyCursor
FETCH NEXT FROM MyCursor into @WBS1, @DescCategory
WHILE @@FETCH_STATUS = 0
BEGIN
select @ptr= textptr(Description)
,@startpos=patindex('%<!--%',Description)
,@endpos=patindex('%-->%',Description)
FROM mytable
where WBS1 Like @WBS1
And DescCategory Like @DescCategory
set @commentlen=@endpos-@startpos-4
set @adjuststart = @startpos+4-1
UpdateText mytable.Description @ptr @adjuststart @commentlen 'DotNetGnat'
FETCH NEXT FROM MyCursor into @WBS1, @DescCategory
END
CLOSE MyCursor
DEALLOCATE MyCursor
Go
-DNG