Solved

Filter vulgar words and limit to 160 stored procedure

Posted on 2012-04-06
3
373 Views
Last Modified: 2012-04-13
Having a table that contains vulgar words,

trying to write a stored procedure that filter a parameter @Message from vulgar words and limit to 160 before insert the statement into table.
0
Comment
Question by:doramail05
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 43

Expert Comment

by:Eugene Z
ID: 37815838
please tell more , clarify

are you using or plan to use Full-text search?
what is you sql server version, edition , serv pack?
160- is number of bad words in 1 message?
what do you plan to do whe n1 or more found ? rollaback? etc
0
 
LVL 1

Accepted Solution

by:
doramail05 earned 0 total points
ID: 37822265
got it oredi

BEGIN 
     SET NOCOUNT ON 
    -- vulgar text filter start
		set @ReturnString=5
		DECLARE @S varchar(max),@Split char(1), @X xml
		SELECT @S = @Message, @Split = ' '
		SELECT @X = CONVERT(xml,'<root><s>' + REPLACE(@S,@Split,'</s><s>') + '</s></root>')
		DECLARE @vtext int
		--set @vtext=

		set @vtext=(select COUNT(*) from(
		SELECT [tValue] = T.c.value('.','varchar(20)'),vulgarword FROM @X.nodes('/root/s') T(c)
		left join tVulgarTable on T.c.value('.','varchar(20)') =tVulgarTable.vulgarword
		)
		t
		where t.vulgarword is not null)
		print @vtext
		
--Vulgar text filter end
    
     if (@vtext>0)
		begin
			set @ReturnString = 0
		end
	if (len(@Message)>160)
		begin
			set @ReturnString = 1
		end
	if (len(@Message)>160 and @vtext>0)
		begin
			set @ReturnString = 3
		end
	
	 if ((len(@Message)<160 or len(@Message)=160) and @ReturnString=5)
		begin
			
			set @ReturnString = 2
		
        
     INSERT INTO dbo.tableA

Open in new window

0
 
LVL 1

Author Closing Comment

by:doramail05
ID: 37841665
assisted from others
0

Featured Post

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A theme is a collection of property settings that allow you to define the look of pages and controls, and then apply the look consistently across pages in an application. Themes can be made up of a set of elements: skins, style sheets, images, and o…
Entering time in Microsoft Access can be difficult. An input mask often bothers users more than helping them and won't catch all typing errors. This article shows how to create a textbox for 24-hour time input with full validation politely catching …
Using examples as well as descriptions, and references to Books Online, show the documentation available for date manipulation functions and by using a select few of these functions, show how date based data can be manipulated with these functions.
Via a live example combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL Server.

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question