Solved

Analysis of table use

Posted on 2016-11-01
7
47 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
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
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

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

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

by Mark Wills Attending one of Rob Farley's seminars the other day, I heard the phrase "The Accidental DBA" and fell in love with it. It got me thinking about the plight of the newcomer to SQL Server...  So if you are the accidental DBA, or, simp…
Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…

773 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