Click here to Skip to main content
15,899,314 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi,

how to find most used records in one table in sql server

thanks in advance
Posted
Comments
koolprasad2003 28-Nov-11 0:30am    
What you mean by Most used records ? records fectched most times ?
K N R 28-Nov-11 0:33am    
yes prasad

To best of my understanding, the history of queries are not stored anywhere, so this is impossible, at least not via using SQL directly.

In principle, you can create some service which re-directs requests to the database and stores statistics or history of the SQL queries in a separate database. In this way, such statistics or history of queries could be preserved, but only for the requests performed via this service. For example, it can be done if all the queries to be taken into account are done via a Web application or a Web service.

—SA
 
Share this answer
 
Comments
koolprasad2003 28-Nov-11 1:16am    
Nice enlightenment SA. 5
Sergey Alexandrovich Kryukov 28-Nov-11 1:25am    
Thank you, Prasad.
--SA
thatraja 28-Nov-11 1:20am    
Right, 5!
Sergey Alexandrovich Kryukov 28-Nov-11 1:25am    
Thank you, Raja.
--SA
As SA said "ABOVE" thing is not possible at least via using SQL directly.
all Queries history stored in .LDF file(Log data file) but we can not read it directly.

You need to customize your code accordingly and set select counter in database. when any column hit increase that counter before fetching column value.
 
Share this answer
 
Comments
thatraja 28-Nov-11 1:21am    
5!
koolprasad2003 28-Nov-11 1:25am    
Thanks Raja
AFAIK you can't. I think you want show the results like Popular, Most rated, Most viewed, etc., For that you need to use something like algorithms. So you need to store additional values(like rating, counts, views) in your table every time.

Look at these CP articles
CodeProject's Article Voting System[^]
Is CodeProject's Voting system really smart?[^]

Check these
Popularity Algorithm[^]
Algorithm for movie recomendations[^]
What is the best algorithm to calculate the most scored item?[^]
Algorithm To Select Most Popular Places from Database[^]
 
Share this answer
 
Comments
koolprasad2003 28-Nov-11 1:26am    
Nice 5.
Sergey Alexandrovich Kryukov 28-Nov-11 1:30am    
Interesting set of links, my 5.
--SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900