|
fizgig
Starting Member
34 Posts |
Posted - 2002-01-18 : 06:27:20
|
| Below is my stored procedure, i want to strip all html tags from the 'tekst' column before returning the recordset. Someone gave me a great function (see below the the stored procedure), but i've read that sql server 7.0 doesn't support user functions. Can anyone give me a hint how to 'merge' the function with the stored procedure? I'm so newbie ;-)CREATE PROCEDURE sp_pagedSearch ( @Page int, @RecsPerPage int, @Forum int, @Zoekopdracht varchar (50) )AS-- We don't want to return the # of rows inserted-- into our temporary table, so turn NOCOUNT ONSET NOCOUNT ON--Create a temporary tableCREATE TABLE #TempPagedSearch( [id] [numeric](18, 0) IDENTITY (1, 1) NOT NULL , [bericht_id] [numeric](18, 0) NULL, [start_bericht] [numeric](18, 0) NULL, [KEY] [numeric] (18,0) NULL , [RANK] [int] NULL , [naam] [varchar] (50) NULL , [verstuurd] [datetime] NULL , [onderwerp] [varchar] (50) NULL , [tekst][text]NULL)-- Insert the rows from tblItems into the temp. tableINSERT INTO #TempPagedSearch (bericht_id, start_bericht, [KEY], RANK, naam, verstuurd, onderwerp, tekst)Select id, start_bericht, [KEY], RANK, naam, verstuurd, onderwerp, tekst FROM ContainsTable(bericht, *, @Zoekopdracht ) S, bericht B WHERE B.id = S.[KEY] AND verwijderd <> 1 AND Forum = @Forum ORDER BY Rank Desc-- Find out the first and last record we wantDECLARE @FirstRec int, @LastRec intSELECT @FirstRec = (@Page - 1) * @RecsPerPageSELECT @LastRec = (@Page * @RecsPerPage + 1)-- Now, return the set of paged records, plus, an indiciation of we-- have more records or not!SELECT *, MoreRecords = ( SELECT COUNT(*) FROM #TempPagedSearch TI WHERE TI.ID >= @LastRec ) , Totaal = (Select count(*) FROM #TempPagedSearch TI) , Eerste = (@FirstRec + 1), Laatste = (@LastRec - 1)FROM #TempPagedSearchWHERE ID > @FirstRec AND ID < @LastRec-- Turn NOCOUNT back OFFSET NOCOUNT OFFGO---------------CREATE FUNCTION cleanLongDesc(@myLongDesc varchar(8000))RETURNS varchar(8000) -- cleaned long descASBEGINDECLARE @fpos int, @spos int, @myNewDesc varchar(8000)SET @myNewDesc=@myLongDescIF CHARINDEX('<', @myLongDesc) > 0BEGINSET @fpos=CHARINDEX('<', @myNewDesc)WHILE @fpos > 0BEGINSET @spos=CHARINDEX('>', @myNewDesc) IF @spos > @fpos SET @myNewDesc=STUFF(@myNewDesc, @fpos, @spos-@fpos+1, '')ELSESET @myNewDesc=STUFF(@myNewDesc, @spos, 1, '')SET @fpos=CHARINDEX('<', @myNewDesc) ENDENDRETURN @myNewDescEND |
|