word count a user

1

Please login or register to vote for this query.

(click on this box to dismiss)

Physics

Q&A for active researchers, academics and students of physics

DECLARE @vendor_id int, @vendor_name nvarchar(max),  
    @message varchar(80), @product nvarchar(50);  

DECLARE vendor_cursor CURSOR FOR
SELECT id, Body
FROM posts 
WHERE posts.OwnerUserId = 109190;

OPEN vendor_cursor

FETCH NEXT FROM vendor_cursor   
INTO @vendor_id, @vendor_name
PRINT FORMATMESSAGE('  id  | count')
WHILE @@FETCH_STATUS = 0
BEGIN  
    DECLARE @count int;
    SELECT @count = (LEN(@vendor_name ) - LEN(replace(@vendor_name , ' ', '')))
    PRINT FORMATMESSAGE('%d |   %d', @vendor_id, @count)
    FETCH NEXT FROM vendor_cursor
    INTO @vendor_id, @vendor_name 
END

Enter Parameters

Options:
Switch sites:
loading Hold tight while we fetch your results