Solved

Analysis of table use

Posted on 2016-11-01
7
63 Views
Last Modified: 2016-11-16
I am using Microsoft SQL Server 2005. I need to know the most recent date/time  when each table was last opened. Is there a utility or query that can provide this information ?
0
Comment
Question by:alcindor
  • 3
  • 3
7 Comments
 
LVL 75

Accepted Solution

by:
Aneesh Retnakaran earned 500 total points
ID: 41869315
What you mean by opened ?  if it is last queried, you are not lucky, there is no such option in sql server . If it is last time the table structure was modified, you can check the sysobjects table.
0
 
LVL 28

Expert Comment

by:Pawan Kumar
ID: 41869390
Use below query to get the info.

Note - Groups is the table Name-

--

SELECT 
name TableName, create_date CreatedDate ,modify_date ModifiedDate, *
FROM SYS.TABLES
WHERE name = 'Groups'


--

Open in new window



o/p

TableName      CreatedDate      ModifiedDate      name      object_id      principal_id      schema_id      parent_object_id      type      type_desc      create_date      modify_date
Groups      2016-11-01 18:02:53.963      2016-11-01 18:02:53.963      Groups      267147997      NULL      1      0      U       USER_TABLE      2016-11-01 18:02:53.963      2016-11-01 18:02:53.963


Try2... for more details.. you should use sys.dm_db_index_usage_stats

--

SELECT DB_NAME(k.[database_id]) DB, OBJECT_NAME(k.[object_id]) TableName, MAX(k.[last_user_lookup]) LastLookUp, MAX(k.[last_user_scan]) LastScan,
MAX(k.[last_user_seek]) LastSeek FROM sys.dm_db_index_usage_stats AS k
WHERE k.[database_id] = DB_ID()
AND k.[object_id] = OBJECT_ID('Groups')
GROUP BY k.[database_id], k.[object_id];


--

Open in new window


o/p

DB                              TableName      LastLookUp      LastScan                              LastSeek
ABCInvestment      Groups               NULL              2016-11-01 18:46:40.443      NULL


Hope it helps !!

Let me know if you need more info here.
0
 
LVL 2

Author Comment

by:alcindor
ID: 41870025
Unfortunately, I did mean queried and not all tables are indexed so it looks like I'm out of luck.
0
Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

 
LVL 28

Expert Comment

by:Pawan Kumar
ID: 41870033
So what is your next question now? Do you some issue
0
 
LVL 2

Author Comment

by:alcindor
ID: 41870096
No further question, as you said "if it is last queried, you are not lucky, there is no such option in sql server".
0
 
LVL 28

Expert Comment

by:Pawan Kumar
ID: 41870127
Great, if you have no further questions.

Regards,
pawan
0
 
LVL 2

Author Closing Comment

by:alcindor
ID: 41890351
As you say there is no such option in SQL server
0

Featured Post

Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
sql Audit table 3 84
How to import SQL 2000 database to SQL 2014 5 161
Table create permissions on SQL Server 2005 9 45
SQL Server 2005 database messed up. Can it be fixed? 4 37
I am showing a way to read/import the excel data in table using SQL server 2005... Suppose there is an Excel file "Book1" at location "C:\temp" with column "First Name" and "Last Name". Now to import this Excel data into the table, we will use…
In SQL Server, when rows are selected from a table, does it retrieve data in the order in which it is inserted?  Many believe this is the case. Let us try to examine for ourselves with an example. To get started, use the following script, wh…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

733 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question