Forum Moderators: open
I run a website and use a weighting system to determine how many points a member is awarded. The points are used as a guide to how knowledgeable the member is about the website's topic.
So far it's working well.
I need to tweak one portion of the stored procedure that calculates the points in order to reduce the impact of forum replies that contain less than ten words.
SET @Points_RepliesPosted = (
SELECT
COUNT(UniqueID)
FROM
tblMB
WHERE
(ForumID NOT IN (8,10,14,15)) AND
(MsgType = 1) AND
(MemberID = @MemberID) AND
(DATEDIFF(day, MsgDateTime, @CONST_DateNow) < @CONST_RecentDays) AND
(there are at least ten words in MsgBody))
Is there a way to calculate the number of words (or spaces) in MsgBody in the above SELECT statement and within the WHERE section?
Thanks.
Declare @intWords AS tinyint
SET @intWords = (SELECT Len(strText)-Len(Replace(strText,' ',''))
Then use @intWords >10 in the WHERE clause
Thanks again. You've helped me solve a huge problem. I am in your debt.
SET @Points_RepliesPosted = (
SELECT
COUNT(UniqueID)
FROM
tblMB
WHERE
(ForumID NOT IN (8,10,14,15)) AND
(MsgType = 1) AND
(MemberID = @MemberID) AND
(DATEDIFF(day, MsgDateTime, @CONST_DateNow) < @CONST_RecentDays) AND
(LEN(MsgBody) - LEN(REPLACE(MsgBody,' ','')) > 10))