SharePoint site collection: Report Last access date and time
Applies To
- SharePoint Server 2007
- SharePoint Server 2010
- SharePoint Foundation 2010
- SharePoint Foundation 2013
- SharePoint Server 2013
Requirement
Report the last access time stamp of site collections to find stale content
Solution
For this requirement, you need two reports as below
- Site collection administrators across all site collections
- Site collections which are under-utilized / not been accessed from a long time.
We will not talk about the first point as it’s very easy and you can prepare it in a simple manner via PowerShell. In case of any queries then please let me know.
Regarding second point which is our main agenda / goal – This can be extracted via SQL Query!
Please refer the following SQL Query which will accomplish this requirement.
SELECT
FullUrl ``AS
'Site URL'``, TimeCreated,
DATEADD(d,DayLastAccessed + 65536, ``CONVERT``(datetime, ``'1/1/1899'``, 101))
AS
lastAccessDate ``FROM
Webs
WHERE
(DayLastAccessed <> 0) ``AND
(FullUrl ``LIKE
N``'sites/%'``) ``ORDER
BY
lastAccessDate
You need to run this query against the specific content database and extract the report.
- Login to your SQL box
- Open SQL Server management studio
- Click on “New Query” from the top
- Change the database from the dropdown
- Select your content database
- Paste the above query in the query box
- Select it (control A)
- Execute it from the top.
- You will get the report in the bottom section.