Open the database in Server explorer or Database Explorer and create tables - KMS_CATEGORIES and KMS_POSTS. The structure is shown in the picture below. ASPNET_USERS table
is already created by ASP.NET. It is shown
as it is parent table for KMS_POSTS.
Create the following stored procedure in the database.
CREATE PROCEDURE dbo.RecentTenPosts
AS
select top 10 pid, title, description, cid, cname,filename,
case filename
when '' then null
else ltrim(str(pid,5) + '_' + filename) end as PhysicalFilename,
postedon, postedby , username, Rating = (excellent * 5 + good * 4 + average * 2 + poor * 1)
/ case excellent + good + average + poor
when 0 then 1
else excellent + good + average + poor
end
from kms_posts p inner join kms_categories c
on p.category = c.cid inner join aspnet_users u
on p.postedby = u.userid
order by pid desc