Thursday, March 29, 2012

Database Statistics

I am trying to find an efficient way to get the number of times that each ro
w
in a table is selected. I want to avoid using triggers.
Any ideas?
Thanks
John
jpd0861@.msn.comIf you're using stored procedures to access data, then I'd simply suggest
extending those to implement table-use auditing. Of course you'd need to kee
p
statistics in a separate table - something like:
PK_column : AccesedTime (default getdate()) : AccessedBy (default system_use
r)
If your db design allows direct access to tables, then maybe your auditing
requirement is just another point in favour of using procedures.
ML|||From the good news/bad news category:
Good news. We don't have SELECT triggers, so you wont have any problem
Bad news, there really isn't any other way to do this unless you are using
stored procedures, and even then it would be a big drag on performance.
Or I am missing something?
----
Louis Davidson - http://spaces.msn.com/members/drsql/
SQL Server MVP
"John" <John@.discussions.microsoft.com> wrote in message
news:77D095BA-04A6-4EB7-83EB-57B28AA21C51@.microsoft.com...
>I am trying to find an efficient way to get the number of times that each
>row
> in a table is selected. I want to avoid using triggers.
> Any ideas?
> Thanks
> John
> jpd0861@.msn.com|||Thank you Louis, I was not clear in my original message. I know that there
are no SELECT triggers in SQL Server...just good old INSERT, UPDATE, and
DELETE.
FYI, I did get an answer about using table-use auditing from ML that seems
to make sense.
"Louis Davidson" wrote:

> From the good news/bad news category:
> Good news. We don't have SELECT triggers, so you wont have any problem
> Bad news, there really isn't any other way to do this unless you are using
> stored procedures, and even then it would be a big drag on performance.
> Or I am missing something?
> --
> ----
--
> Louis Davidson - http://spaces.msn.com/members/drsql/
> SQL Server MVP
>
> "John" <John@.discussions.microsoft.com> wrote in message
> news:77D095BA-04A6-4EB7-83EB-57B28AA21C51@.microsoft.com...
>
>|||I agree, I just wanted to be clear that without procs this would not be
possible. I rarely expect that people are actually using stored procedures,
but clearly this is yet another reason why they are so excellent.
----
Louis Davidson - http://spaces.msn.com/members/drsql/
SQL Server MVP
"John" <John@.discussions.microsoft.com> wrote in message
news:6D10890D-C733-4673-852F-81C747F2EF10@.microsoft.com...
> Thank you Louis, I was not clear in my original message. I know that there
> are no SELECT triggers in SQL Server...just good old INSERT, UPDATE, and
> DELETE.
> FYI, I did get an answer about using table-use auditing from ML that seems
> to make sense.
> "Louis Davidson" wrote:
>

No comments:

Post a Comment