RE: Number of Occurrences

RE: Number of Occurrences

 

  

Srikanta,
Below is a SQL Server procedure. You can modify it to meet your requirements.

ALTER PROCEDURE dbo.SearchAndReplace

--here we'll accept some values for the search string and the replace string.
@FindString varchar(8000),
@ReplaceString varchar(8000)
AS
SET NOCOUNT ON

DECLARE @TextPointer varbinary( 16 )
DECLARE @DeleteLength int
DECLARE @OffSet int

SELECT @TextPointer = textptr( MyTextField)
FROM MyTable
SET @DeleteLength = len( @FindString )
SET @OffSet = 0
WHILE ( SELECT count( * )
FROM MyTable
WHERE patindex( '%' + @FindString + '%', MyTextField) <> 0
) > 0
BEGIN
SELECT @OffSet = patindex( '%' + @FindString + '%', MyTextField) - 1
FROM MyTable
WHERE patindex( '%' + @FindString + '%', MyTextField) <> 0
UPDATETEXT MyTextField
@TextPointer
@OffSet
@DeleteLength
@ReplaceString
END
RETURN


-----Original Message-----
From: Edwards Ed
[mailto:oracledba-ezmlmshield-x21806793.[Email address protected]
Sent: Friday, December 30, 2005 9:13 AM
To: LazyDBA Discussion
Subject: RE: Number of Occurance


Srikanta,
Here is an Oracle link.

http://www.oracle.com/technology/oramag/code/tips2004/121304.html



-----Original Message-----
From: Srikanta L
[mailto:oracledba-ezmlmshield-x99850403.[Email address protected]
Sent: Friday, December 30, 2005 7:07 AM
To: LazyDBA Discussion
Subject: Number of Occurance


Dear All

How to find the number of occurance of some string in the given field in both SQL & ORACLE database.

Srikanta.L

--------------------------------------------------------------------------------




--------
website: http://www.LazyDBA.com
Please don't reply to RTFM questions
Oracle documentation is here: http://tahiti.oracle.com
To unsubscribe: see http://www.lazydba.com/unsubscribe.html
To subscribe: see http://www.lazydba.com
By using this list you agree to these terms:http://www.lazydba.com/legal.html

Please take a few minutes to provide feedback on the quality of service you received. The Department of Education values your feedback as a customer. Commissioner John L. Winn is committed to continuously assessing and improving the level and quality of services provided to you by Department staff. Simply click on this link to the "DOE Customer Survey". Thank you in advance for completing the survey.

DOE Customer Survey


--------
website: http://www.LazyDBA.com
Please don't reply to RTFM questions
Oracle documentation is here: http://tahiti.oracle.com
To unsubscribe: see http://www.lazydba.com/unsubscribe.html
To subscribe: see http://www.lazydba.com
By using this list you agree to these terms:http://www.lazydba.com/legal.html

Oracle LazyDBA home page