473,414 Members | 1,888 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,414 software developers and data experts.

Counting number of selects made

COUNTING NUMBER OF SELECTS MADE


table mytable {
id, data, hits
}

users view data from the table:

SELECT data FROM mytable WHERE id=1 --for example
SELECT data FROM mytable WHERE id=20 --for example
....
How do increment the hits column without replacing the above with the below?

update mytable SET hits=hits+1 WHERE id=1;SELECT data FROM mytable WHERE id=1
update mytable SET hits=hits+1 WHERE id=1;SELECT data FROM mytable WHERE id=20
....
I believe triggers can't be used as they only trigger on update/delete events.

I'm using sql server 2000 (latest patches) with asp

Thanks
Alex
Jul 20 '05 #1
3 2154
There is no reliable way to do this. One option is to use the profiler to
track the SELECT statements and dump them into a file. This can be exported
in a SQL Server table later on.

--
- Anith
( Please reply to newsgroups only )
Jul 20 '05 #2
"Anith Sen" <an***@bizdatasolutions.com> wrote in message news:<M4*********************@bgtnsc05-news.ops.worldnet.att.net>...
There is no reliable way to do this. One option is to use the profiler to
track the SELECT statements and dump them into a file. This can be exported
in a SQL Server table later on.


I use stored procedures for everything. This is one reason why. You
can add auditting information whenever you like.

In a related story, I also have an USERID parameter on every stored
procedure for future use. (Then you can log who queried what).
Jul 20 '05 #3
A Seel (al*********@hotmail.com) writes:
COUNTING NUMBER OF SELECTS MADE

table mytable {
id, data, hits
}
users view data from the table:
SELECT data FROM mytable WHERE id=1 --for example
SELECT data FROM mytable WHERE id=20 --for example
...
How do increment the hits column without replacing the above with the
below?


As Anith said, there is no supported way to this, other than to run a
Profiler trace.

Lumigent has a tool called Entegra, which they say will include a module
that audits who views which data. Their web site says that this module
is planned for release Q2, 2003, so one would expect it to appear soon.
See www.lumigent.com for more information.

--
Erland Sommarskog, SQL Server MVP, so****@algonet.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinf...2000/books.asp
Jul 20 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Victor Engmark | last post by:
When looking for a method to fetch unique elements and counting the number of occurences of each of them, I found quite a lot of gross examples of complex XSL. But after realizing the subtle...
15
by: parksch2 | last post by:
I've spent quite a bit of time (way more than I'd like) today looking for an answer to what I thought would be a simple question. I simply need to get the count of items within some nodes up to the...
5
by: rob.guitar.rob | last post by:
Hi, This may be a stupid question, but if you count a self axe will it always return 1? For example: count(self::*) and
3
by: Megan | last post by:
hi everybody- i'm having a counting problem i hope you guys and gals could give me some help with. i have a query that retrieves a bevy of information from several different tables. first let...
18
by: ChadDiesel | last post by:
I appreciate the help on this group. I know I've posted a lot here the last couple of weeks, but I was thrown into a database project at my work with very little Access experience. No other...
1
by: j | last post by:
Hi, I've been trying to do line/character counts on documents that are being uploaded. As well as the "counting" I also have to remove certain sections from the file. So, firstly I was working...
1
by: Jerry | last post by:
We have a 10-question quiz for kids, each question being a yes or no answer using radio selections. I'd like to keep a current total of yes's and no's at the bottom of the quiz (if the user selects...
1
by: oec.deepak | last post by:
Hi Cn any one telll me what is Reference counting in C++.
3
by: nitric | last post by:
hey guys, i'm really stuck on this program. It's basically a survey and I have to ask people what drinks they like. 1-4, coffee tea oj and lemonade. i'm having trouble counting the TOTAL NUMBER...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.