Fixed logic for excluding link text from search
This commit is contained in:
parent
eeef43e48e
commit
a646c399a3
@ -10364,33 +10364,6 @@ IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[vefn_FirstLink]'
|
|||||||
DROP FUNCTION [vefn_FirstLink];
|
DROP FUNCTION [vefn_FirstLink];
|
||||||
GO
|
GO
|
||||||
|
|
||||||
/*
|
|
||||||
select .dbo.vefn_FirstLink('asdasdadsasd' + char(21) + 'asdasdasd\vasdasdasd', 2)
|
|
||||||
select .dbo.vefn_FirstLink('asdasdadsasd' + char(21) + 'asdasdasd\vasdasdasd', 1)
|
|
||||||
select .dbo.vefn_FirstLink('asdasdadsasd' + char(21) + 'asdasdasd\vasdasdasd', 0)
|
|
||||||
*/
|
|
||||||
|
|
||||||
CREATE FUNCTION [dbo].[vefn_FirstLink](@text nvarchar(MAX),@includeLink int)
|
|
||||||
RETURNS int
|
|
||||||
WITH EXECUTE AS OWNER
|
|
||||||
AS
|
|
||||||
BEGIN
|
|
||||||
DECLARE @index int
|
|
||||||
SET @index = 0
|
|
||||||
if(@includeLink = 2)
|
|
||||||
RETURN 0
|
|
||||||
if(@includeLink = 1)
|
|
||||||
return CHARINDEX('\v' , @text)
|
|
||||||
DECLARE @index2 int
|
|
||||||
SET @index = PATINDEX('%[' + nchar(9574)+nchar(9516)+nchar(21) + ']%',@text)
|
|
||||||
return @index
|
|
||||||
END
|
|
||||||
GO
|
|
||||||
-- Display the status of Proc creation
|
|
||||||
IF (@@Error = 0) PRINT 'ScalarFunction Creation: vefn_FirstLink Succeeded'
|
|
||||||
ELSE PRINT 'ScalarFunction Creation: vefn_FirstLink Error on Creation'
|
|
||||||
GO
|
|
||||||
|
|
||||||
/****** Object: StoredProcedure [vefn_FixSearchString] ******/
|
/****** Object: StoredProcedure [vefn_FixSearchString] ******/
|
||||||
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[vefn_FixSearchString]') AND OBJECTPROPERTY(id,N'IsScalarFunction') = 1)
|
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[vefn_FixSearchString]') AND OBJECTPROPERTY(id,N'IsScalarFunction') = 1)
|
||||||
DROP FUNCTION [vefn_FixSearchString];
|
DROP FUNCTION [vefn_FixSearchString];
|
||||||
@ -10603,13 +10576,11 @@ AS
|
|||||||
BEGIN
|
BEGIN
|
||||||
DECLARE @index int
|
DECLARE @index int
|
||||||
DECLARE @index2 int
|
DECLARE @index2 int
|
||||||
SET @index = .dbo.vefn_FirstLink(@text,@includeLink)
|
-- Strip Links
|
||||||
while (@index != 0)
|
IF @includeLink = 0 -- Remove Links
|
||||||
BEGIN
|
SET @text = [dbo].[vefn_RemoveRange](@text,'<START]' ,'[END>')
|
||||||
SET @index2 = CHARINDEX('\v0' , @text)
|
IF @includeLink < 2 -- Remove Comments
|
||||||
SET @text = substring(@text,1,@index-1) + substring(@text,@index2+3,len(@text))
|
SET @text = [dbo].[vefn_RemoveRange](@text,'\v' ,'\v0')
|
||||||
SET @index = .dbo.vefn_FirstLink(@text,@includeLink)
|
|
||||||
END
|
|
||||||
if(@includeRtfFormatting=0)
|
if(@includeRtfFormatting=0)
|
||||||
-- Remove Rtf Formatting
|
-- Remove Rtf Formatting
|
||||||
BEGIN
|
BEGIN
|
||||||
@ -10675,6 +10646,49 @@ IF (@@Error = 0) PRINT 'ScalarFunction Creation: vefn_RemoveExtraText Succeeded'
|
|||||||
ELSE PRINT 'ScalarFunction Creation: vefn_RemoveExtraText Error on Creation'
|
ELSE PRINT 'ScalarFunction Creation: vefn_RemoveExtraText Error on Creation'
|
||||||
GO
|
GO
|
||||||
|
|
||||||
|
/****** Object: StoredProcedure [vefn_RemoveRange] ******/
|
||||||
|
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[vefn_RemoveRange]') AND OBJECTPROPERTY(id,N'IsScalarFunction') = 1)
|
||||||
|
DROP FUNCTION [vefn_RemoveRange];
|
||||||
|
GO
|
||||||
|
|
||||||
|
/*
|
||||||
|
SELECT ContentID, text, [dbo].[vefn_RemoveRange](text,'<START]','[END>') StrippedText
|
||||||
|
from contents
|
||||||
|
where contentid in (select top 25 ContentID from contents where text like '%[[]END>%')
|
||||||
|
|
||||||
|
select top 25 * from contents where text like '%[[]END>%'
|
||||||
|
|
||||||
|
SELECT ContentID, [dbo].[vefn_RemoveRange](text,'<START]','[END>') StrippedText
|
||||||
|
from contents
|
||||||
|
where contentid =189
|
||||||
|
*/
|
||||||
|
|
||||||
|
CREATE FUNCTION [dbo].[vefn_RemoveRange](@text nvarchar(MAX),@startToken nvarchar(MAX), @endToken nvarchar(MAX))
|
||||||
|
RETURNS varchar(MAX)
|
||||||
|
WITH EXECUTE AS OWNER
|
||||||
|
AS
|
||||||
|
BEGIN
|
||||||
|
DECLARE @index int
|
||||||
|
DECLARE @index2 int
|
||||||
|
DECLARE @lenStartToken int
|
||||||
|
DECLARE @lenEndToken int
|
||||||
|
SET @lenStartToken = len(@startToken)
|
||||||
|
SET @lenEndToken = len(@endToken)
|
||||||
|
SET @index = CHARINDEX(@startToken , @text)
|
||||||
|
while (@index != 0)
|
||||||
|
BEGIN
|
||||||
|
SET @index2 = CHARINDEX(@endToken , @text, @index + @lenStartToken)
|
||||||
|
SET @text = substring(@text,1,@index-1) + substring(@text,@index2+@lenEndToken,len(@text))
|
||||||
|
SET @index = CHARINDEX(@startToken , @text)
|
||||||
|
END
|
||||||
|
RETURN @text
|
||||||
|
END
|
||||||
|
GO
|
||||||
|
-- Display the status of Proc creation
|
||||||
|
IF (@@Error = 0) PRINT 'ScalarFunction Creation: vefn_RemoveRange Succeeded'
|
||||||
|
ELSE PRINT 'ScalarFunction Creation: vefn_RemoveRange Error on Creation'
|
||||||
|
GO
|
||||||
|
|
||||||
/****** Object: StoredProcedure [vefn_SiblingAndChildrenItems] ******/
|
/****** Object: StoredProcedure [vefn_SiblingAndChildrenItems] ******/
|
||||||
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[vefn_SiblingAndChildrenItems]') AND OBJECTPROPERTY(id,N'IsTableFunction') = 1)
|
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[vefn_SiblingAndChildrenItems]') AND OBJECTPROPERTY(id,N'IsTableFunction') = 1)
|
||||||
DROP FUNCTION [vefn_SiblingAndChildrenItems];
|
DROP FUNCTION [vefn_SiblingAndChildrenItems];
|
||||||
|
Loading…
x
Reference in New Issue
Block a user