This commit is contained in:
parent
1a65b51312
commit
62334a105d
@ -2381,3 +2381,55 @@ GO
|
||||
IF (@@Error = 0) PRINT 'TableFunction Creation: vefn_SiblingAndChildrenItemsByProc Succeeded'
|
||||
ELSE PRINT 'TableFunction Creation: vefn_SiblingAndChildrenItemsByProc Error on Creation'
|
||||
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
|
||||
*/
|
||||
|
||||
/*****************************************************************************
|
||||
Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
|
||||
Copyright 2012 - Volian Enterprises, Inc. All rights reserved.
|
||||
*****************************************************************************/
|
||||
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
|
||||
DECLARE @lastIndex int
|
||||
SET @lenStartToken = len(@startToken)
|
||||
SET @lenEndToken = len(@endToken)
|
||||
SET @index = CHARINDEX(@startToken , @text)
|
||||
SET @lastIndex = -1
|
||||
while (@index != 0)
|
||||
BEGIN
|
||||
SET @index2 = CHARINDEX(@endToken , @text, @index + @lenStartToken)
|
||||
if (@index2>0)
|
||||
SET @text = substring(@text,1,@index-1) + substring(@text,@index2+@lenEndToken,len(@text))
|
||||
SET @lastIndex = @index
|
||||
SET @index = CHARINDEX(@startToken , @text)
|
||||
if (@index = @lastIndex) SET @index = 0
|
||||
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
|
Loading…
x
Reference in New Issue
Block a user