doramail05
asked on
Filter Vulgar words and detect only 160 words in Stored Procedure
Trying to filter vulgar words and limit to 160 words in @Message variable before insert statement, and return several strings forout put,
@ExpireDate DATETIME,
@ReturnString VARCHAR(100) OUTPUT
AS
BEGIN
SET NOCOUNT ON
IF (CHARINDEX('bitch', @Message) > 0)
@ReturnString = 'Please do not use vulgar words'
ELSE
INSERT INTO dbo.fSMSBuffB
(
fBatchNo ,
fOrderNo ,
fRefNo ,
fPriority ,
fFromID ,
fMobileNumber ,
fMessage ,
fInputDate ,
fSuccessDate ,
fExpireDate
)
VALUES
(
@BatchNo ,
@OrderNo ,
@Refno ,
@Priority ,
@FromID ,
@MobileNumber ,
@Message ,
@InputDate ,
@SuccessDate ,
@ExpireDate
)
END
In your code, you could do
BEGIN
SET NOCOUNT ON
DECLARE @status int
ValidateWords(@Message, @Status)
IF @Status = 1
@ReturnString = 'Please do not use vulgar words'
ELSE
.....................
BEGIN
SET NOCOUNT ON
DECLARE @status int
ValidateWords(@Message, @Status)
IF @Status = 1
@ReturnString = 'Please do not use vulgar words'
ELSE
.....................
ASKER
guess should be making a table to store and retrieve it,
But what if just without the method,
only by using this stored procedure to filter several words
But what if just without the method,
only by using this stored procedure to filter several words
That would become a little bit messy and hard to maintain, think adding a new word to your check.
You will end up with multiple conditions, as many as the words you would like to filter eg
if (CHARINDEX('xxx', @Message, 1) >=1) OR (CHARINDEX('yyy', @Message, 1) >=1) OR ..........
You will end up with multiple conditions, as many as the words you would like to filter eg
if (CHARINDEX('xxx', @Message, 1) >=1) OR (CHARINDEX('yyy', @Message, 1) >=1) OR ..........
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
assist from other
Then why are your not awarding points for assists?
Then why are your not awarding points for assists?
ASKER
assist from other
something very simple like
Open in new window