Solved

Filter vulgar words and limit to 160 stored procedure

Posted on 2012-04-06
3
324 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
  • 2
3 Comments
 
LVL 42

Expert Comment

by:EugeneZ
Comment Utility
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
Comment Utility
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
Comment Utility
assisted from others
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

When you hear the word proxy, you may become apprehensive. This article will help you to understand Proxy and when it is useful. Let's talk Proxy for SQL Server. (Not in terms of Internet access.) Typically, you'll run into this type of problem w…
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…
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.
Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…

763 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now