- execute the results to text then can copy and paste to run it
- excluded the system database
keep track and sharing on my sharepoint knowledge :) nice to meet you all
which country user step here?
Tag Cloud
Monday, June 5, 2017
SQL script add user to all content database
Saturday, May 7, 2016
SQL query : Shrink SQL log file
Sql query check instance name and sever name
Friday, April 1, 2016
SharePoint 2013 RBS setup for second content database
just sharing some command for setup on the following content DB after first RBS content DB is enable ,
http://go.microsoft.com/fwlink/?LinkID=188395&clcid=0x409 >> download for RBS.msi x64 package which is 5287KB file size is the correct version to support second content DB. if u downloaded the previous version then mind be not working.
SQL Query
==========
use wss_content
if not exists (select * from sys.symmetric_keys where name = N'##MS_DatabaseMasterKey##') create master key encryptionby password = N'Admin Key Password !2#4'
use wss_content
if not exists (select groupname from sysfilegroups where groupname=N'RBSFilestreamProvider')alter database wss_content add filegroup RBSFilestreamProvider
contains filestream
use wss_content
alter database wss_content add file (name = RBSFilestreamFile, filename = 'F:\Blobstore') to filegroup RBSFilestreamProvider
first content db enabel rbs , run at SQL server
===================================================
msiexec /qn /lvx* rbs_install_log.txt /i RBS.msi TRUSTSERVERCERTIFICATE=true FILEGROUP=PRIMARY DBNAME="WSS_Content_RBS" DBINSTANCE="DBPRD02" FILESTREAMFILEGROUP=RBSFilestreamProvider FILESTREAMSTORENAME=FilestreamProvider_1
first content db enabel rbs , run at application and web front end server
=====================================================
msiexec /qn /lvx* rbs_install_log.txt /i RBS.msi DBNAME="WSS_Content" DBINSTANCE="DBInstance Name" ADDLOCAL="Client,Docs,Maintainer,ServerScript,FilestreamClient,FilestreamServer"
second content db :need to enabe RBS ( run at sql or applicatin server)
=================================================================
msiexec /qn /lvx* rbs_install_log.txt /i RBS.msi REMOTEBLOBENABLE=1 FILESTREAMPROVIDERENABLE=1 FILESTREAMSTORENAME=FilestreamProvider_1 DBNAME="WSS_Content" ADDLOCAL="EnableRBS,FilestreamRunScript" DBINSTANCE="DBPRD02"
second content db : wfe install for rbs second content db
==========================================================
msiexec /qn /lvx* rbs_install_log.txt /i RBS.msi TRUSTSERVERCERTIFICATE=true FILEGROUP=PRIMARY DBNAME="WSS_Content" DBINSTANCE="DBPRD02" FILESTREAMFILEGROUP=RBSFilestreamProvider FILESTREAMSTORENAME=FilestreamProvider_1
powershell enable RBS
====================
$cdb = Get-SPContentDatabase WSS_Content
$rbss = $cdb.RemoteBlobStorageSettings
$rbss.Installed()
$rbss.Enable()
$rbss.SetActiveProviderName($rbss.GetProviderNames()[0])
$rbss
powershell migrate sql data to RBS
=================================
$cdb = Get-SPContentDatabase WSS_Content
$rbss = $cdb.RemoteBlobStorageSettings
$rbss.SetActiveProviderName($rbss.GetProviderNames()[0])
$rbss.Migrate()
Last Step :
========
Need to add application pool service account to the content DB for DB owner role.
*if not granted db role for application pool account, when you upload file will see error message . File name can't contain the following characters : &?<>#{}%~/\.
more information :
http://blogs.technet.com/b/pramodbalusu/archive/2011/07/09/rbs-and-sharepoint-2010.aspx
Friday, March 18, 2016
Query to check which backup task is running at back end
Tuesday, January 11, 2011
Some queries with Share[point content DB
Some queries with these tables:
-- Query to get all the top level site collections
SELECT SiteId AS Siteid, Id AS Webid, FullUrl AS FURL, Title, Author, TimeCreated FROM dbo.Webs WHERE (ParentWebId IS NULL)
-- Query to get all the child sites in a site collection
SELECT SiteId AS Siteid, Id AS Webid, FullUrl AS FURl, Title, Author, TimeCreated FROM dbo.Webs WHERE (NOT (ParentWebId IS NULL))
-- Query to get all the SharePoint groups in a site collection
SELECT dbo.Webs.SiteId, dbo.Webs.Id, dbo.Webs.FullUrl, dbo.Webs.Title, dbo.Groups.ID AS Expr1, dbo.Groups.Title AS Expr2, dbo.Groups.Description FROM dbo.Groups INNER JOIN dbo.Webs ON dbo.Groups.SiteId = dbo.Webs.SiteId
-- Query to get all the users in a site collection
SELECT dbo.Webs.SiteId, dbo.Webs.Id, dbo.Webs.FullUrl, dbo.Webs.Title, dbo.UserInfo.tp_ID, dbo.UserInfo.tp_DomainGroup, dbo.UserInfo.tp_SiteAdmin, dbo.UserInfo.tp_Title, dbo.UserInfo.tp_Email FROM dbo.UserInfo INNER JOIN dbo.Webs ON dbo.UserInfo.tp_SiteID = dbo.Webs.SiteId
-- Query to get all the members of the SharePoint Groups
SELECT dbo.Groups.ID, dbo.Groups.Title, dbo.UserInfo.tp_Title, dbo.UserInfo.tp_Login FROM dbo.GroupMembership INNER JOIN dbo.Groups ON dbo.GroupMembership.SiteId = dbo.Groups.SiteId INNER JOINdbo.UserInfo ON dbo.GroupMembership.MemberId = dbo.UserInfo.tp_ID
-- Query to get all the sites where a specific feature is activated
SELECT dbo.Webs.Id AS WebGuid, dbo.Webs.Title AS WebTitle, dbo.Webs.FullUrl AS WebUrl, dbo.Features.FeatureId, dbo.Features.TimeActivatedFROM dbo.Features INNER JOIN dbo.Webs ON dbo.Features.SiteId = dbo.Webs.SiteId AND dbo.Features.WebId = dbo.Webs.Id WHERE (dbo.Features.FeatureId = '00AFDA71-D2CE-42fg-9C63-A44004CE0104')
-- Query to get all the users assigned to roles
SELECT dbo.Webs.Id, dbo.Webs.Title, dbo.Webs.FullUrl, dbo.Roles.RoleId, dbo.Roles.Title AS RoleTitle, dbo.UserInfo.tp_Title, dbo.UserInfo.tp_Login FROM dbo.RoleAssignment INNER JOIN dbo.Roles ON dbo.RoleAssignment.SiteId = dbo.Roles.SiteId AND dbo.RoleAssignment.RoleId = dbo.Roles.RoleId INNER JOIN dbo.Webs ON dbo.Roles.SiteId = dbo.Webs.SiteId AND dbo.Roles.WebId = dbo.Webs.Id INNER JOIN dbo.UserInfo ON dbo.RoleAssignment.PrincipalId = dbo.UserInfo.tp_ID
-- Query to get all the SharePoint groups assigned to roles
SELECT dbo.Webs.Id, dbo.Webs.Title, dbo.Webs.FullUrl, dbo.Roles.RoleId, dbo.Roles.Title AS RoleTitle, dbo.Groups.Title AS GroupName FROM dbo.RoleAssignment INNER JOINdbo.Roles ON dbo.RoleAssignment.SiteId = dbo.Roles.SiteId AND dbo.RoleAssignment.RoleId = dbo.Roles.RoleId INNER JOIN dbo.Webs ON dbo.Roles.SiteId = dbo.Webs.SiteId AND dbo.Roles.WebId = dbo.Webs.Id INNER JOIN dbo.Groups ON dbo.RoleAssignment.SiteId = dbo.Groups.SiteId AND dbo.RoleAssignment.PrincipalId = dbo.Groups.ID
You can also find interesting to read Different Database created with SharePoint
Copy From http://manish-sharepoint.blogspot.com/2008/06/some-important-tables-with-sharepoint.html
Tuesday, December 14, 2010
querying membership data
Found one very usefull query from internet :
http://johnlivingstontech.blogspot.com/2009/11/sharepoint-2007-five-very-helpful-yet.html
thanks for the creator to share this!! Below is the SQL query
1. Select Groups By URL
USE [WSS_Content]
CREATE PROCEDURE [dbo].[usp_SelectGroupsByUrl]
@url NVARCHAR(255)
AS
BEGIN
SELECT Groups.ID AS "GroupID", Groups.Title AS "GroupTitle", Webs.Title AS WebTitle, Webs.FullURL AS WebURL, Roles.Title AS "RoleTitle"
FROM RoleAssignment WITH (NOLOCK)
INNER JOIN Roles WITH (NOLOCK) ON Roles.SiteId = RoleAssignment.SiteId
AND Roles.RoleId = RoleAssignment.RoleId
INNER JOIN Groups WITH (NOLOCK) ON Groups.SiteId = RoleAssignment.SiteId
AND Groups.ID = RoleAssignment.PrincipalId
INNER JOIN Sites WITH (NOLOCK) ON Sites.Id = RoleAssignment.SiteId
INNER JOIN Perms WITH (NOLOCK) ON Perms.SiteId = RoleAssignment.SiteId
AND Perms.ScopeId = RoleAssignment.ScopeId
INNER JOIN Webs WITH (NOLOCK) ON Webs.Id = Perms.WebId
WHERE ((Webs.FullUrl = @url) OR (@url IS NULL))
ORDER BY
Groups.Title, Webs.Title, Perms.ScopeUrl
END
Sample Query
EXEC usp_SelectGroupsByUrl 'Sites/HR/Pay'
Results
| GroupID | GroupTitle | WebTitle | WebURL | RoleTitle |
| 71 | Manager | Accounting | Sites/HR/PAY | View Only |
| 74 | Acct Sr Manager | Accounting | Sites/HR/PAY | Full Control |
| 75 | Member | Accounting | Sites/HR/PAY | View Only |
| 76 | Viewer | Accounting | Sites/HR/PAY | View Only |
2. Select Groups By URL and User
USE [WSS_Content]
CREATE PROCEDURE [dbo].[usp_SelectGroupsByUrlUser]
@login NVARCHAR(255),
@url NVARCHAR(255)
AS
BEGIN
SELECT G.ID AS "GroupID", G.Title AS "GroupTitle", W.Title AS WebTitle, W.FullURL AS WebURL, R.Title AS "RoleTitle"
FROM RoleAssignment AS RA WITH (NOLOCK)
INNER JOIN Roles AS R WITH (NOLOCK) ON R.SiteId = RA.SiteId
AND R.RoleId = RA.RoleId
INNER JOIN Groups AS G WITH (NOLOCK) ON G.SiteId = RA.SiteId
AND G.ID = RA.PrincipalId
INNER JOIN Sites AS S WITH (NOLOCK) ON S.Id = RA.SiteId
INNER JOIN Perms AS P WITH (NOLOCK) ON P.SiteId = RA.SiteId
AND P.ScopeId = RA.ScopeId
INNER JOIN Webs AS W WITH (NOLOCK) ON W.Id = P.WebId
WHERE ((W.FullUrl = @url) OR (@url IS NULL))
AND G.ID IN
(
SELECT Groups.ID FROM GroupMemberShip WITH (NOLOCK)
INNER JOIN Groups ON GroupMembership.GroupID = Groups.ID
INNER JOIN UserInfo ON GroupMembership.MemberID = UserInfo.tp_ID
WHERE ((tp_Login = @login) OR (@login IS NULL))
)
ORDER BY
G.Title, W.Title, P.ScopeUrl
END
Sample Query
EXEC usp_SelectGroupsByUrlUser 'acmedomain\jdoe', 'Sites/HR/Pay'
Results
| GroupID | GroupTitle | WebTitle | WebURL | RoleTitle |
| 74 | Sr Manager | Accounting | Sites/HR/PAY | Full Control |
3. Select Groups By User Login
USE [WSS_Content]
CREATE PROCEDURE [dbo].[usp_SelectGroupsByUserLogin]
@login NVARCHAR(255)
AS
BEGIN
SELECT DISTINCT Groups.ID AS "GroupID", Groups.Title AS "GroupTitle"
FROM GroupMemberShip WITH (NOLOCK)
INNER JOIN Groups WITH (NOLOCK) ON GroupMembership.GroupID = Groups.ID
INNER JOIN UserInfo WITH (NOLOCK) ON GroupMembership.MemberID = UserInfo.tp_ID
WHERE ((tp_Login = @login) OR (@login IS NULL))
ORDER BY Groups.Title
END
Sample Query
EXEC usp_SelectGroupsByUserLogin 'acmedomain\jdoe'
Results
| GroupID | GroupTitle |
| 74 | Sr Manager |
| 52 | Corporate Viewer |
| 14 | HR Team Member |
4. Select Users By Group
USE [WSS_Content]
CREATE PROCEDURE [dbo].[usp_SelectUsersByGroup]
@groupTitle NVARCHAR(255)
AS
BEGIN
SELECT dbo.UserInfo.tp_ID AS UserID, dbo.UserInfo.tp_Title AS UserTitle, dbo.UserInfo.tp_Login AS UserLogin, dbo.UserInfo.tp_Email AS UserEmail, dbo.Groups.ID AS GroupsID, dbo.Groups.Title AS GroupsTitle
FROM UserInfo WITH (NOLOCK)
INNER JOIN GroupMembership WITH (NOLOCK) ON UserInfo.tp_ID = GroupMembership.MemberID
INNER JOIN Groups WITH (NOLOCK) ON GroupMembership.GroupID = Groups.ID
WHERE ((dbo.Groups.Title = @groupTitle) OR (@groupTitle IS NULL))
ORDER by dbo.UserInfo.tp_Login
END
Sample Query
EXEC usp_SelectUsersByGroup 'HR Team Member'
Results
| UserID | UserTitle | UserLogin | UserEmail | GroupsID | GroupsTitle |
| 23 | Doe, John | acmedomain\jdoe | 14 | HR Team Member | |
| 20 | Doe, Jane | acmedomain\jadoe | 14 | HR Team Member | |
| 2 | Smith, Bob | acmedomain\bsmith | 14 | HR Team Member | |
| 24 | Yamamoto, Kazue | acmedomain\kyamamoto | 14 | HR Team Member | |
| 46 | Nakamura, Ichiro | acmedomain\inakamura | 14 | HR Team Member |
5 Select Users By Groups
USE [WSS_Content]
CREATE PROCEDURE [dbo].[usp_SelectUsersByGroups]
@groupTitles VARCHAR(1000)
AS
BEGIN
DECLARE @idoc INT
EXEC sp_xml_preparedocument @idoc OUTPUT, @groupTitles
SELECT dbo.UserInfo.tp_ID AS UserID, dbo.UserInfo.tp_Title AS UserTitle, dbo.UserInfo.tp_Login AS UserLogin, dbo.UserInfo.tp_Email AS UserEmail, Groups.Title AS GroupTitle
FROM UserInfo WITH (NOLOCK)
INNER JOIN GroupMembership WITH (NOLOCK) ON UserInfo.tp_ID = GroupMembership.MemberID
INNER JOIN Groups WITH (NOLOCK) ON GroupMembership.GroupID = Groups.ID
JOIN OPENXML(@idoc, '/Root/Group', 0) WITH (Name VARCHAR(100)) AS g
ON dbo.Groups.Title = g.Name
ORDER by dbo.Groups.Title, dbo.UserInfo.tp_Title
END
Sample Query
EXEC usp_SelectUsersByGroups '<Root><Group Name="HR Team Member"></Group><Group Name="Acct Sr Managers"></Group></Root>'
Results
| UserID | UserTitle | UserLogin | UserEmail | GroupsID | GroupsTitle |
| 23 | Doe, John | acmedomain\jdoe | 14 | HR Team Member | |
| 20 | Doe, Jane | acmedomain\jadoe | 14 | HR Team Member | |
| 2 | Smith, Bob | acmedomain\bsmith | 14 | HR Team Member | |
| 24 | Yamamoto, Kazue | acmedomain\kyamamoto | 14 | HR Team Member | |
| 46 | Nakamura, Ichiro | acmedomain\inakamura | 14 | HR Team Member | |
| 7 | Horowitz, Rick | acmedomain\rhorowitz | 15 | Acct Sr Managers | |
| 3 | Davis, Jiro | acmedomain\jdavis | 15 | Acct Sr Managers |
user's list of web sites in SharePoint : SharePoint
SELECT DISTINCT w.Title, r.WebId, r.Title AS accessLevel, ui.tp_Login,
ui.tp_DomainGroup, ui.tp_Title, w.FullUrl, w.AlternateCSSUrl,
p.ScopeUrl
FROM RoleAssignment AS ra INNER JOIN
Roles AS r ON r.SiteId = ra.SiteId AND r.RoleId
= ra.RoleId INNER JOIN
UserInfo AS ui ON ui.tp_SiteID = ra.SiteId AND
ui.tp_ID = ra.PrincipalId INNER JOIN
Sites AS s ON s.Id = ra.SiteId INNER JOIN
Perms AS p ON p.SiteId = ra.SiteId AND p.ScopeId
= ra.ScopeId INNER JOIN
Webs AS w ON w.Id = p.WebId
copy from Forum
Discovering all workflows in SharePoint farm
I got a question from user to identify all workflow in my Sharepoint environment. I tried to identify some out of box option but could not find one. After that I have to put my DB cap on and write query on backend content database of MOSS farm to get list all sites and sub containers which are having active workflow running in them. Here is the query :
select distinct(w.fullurl) as SiteName, L.tp_Title as ListName from webs w,workflow wf , Alllists L where w.id=wf.webid and w.siteId=wf.siteId and wf.listId=L.tp_Id
Copy from Here
Tuesday, November 2, 2010
How to confirm your update item is going to do incremental crawl or not ?
Search problem for the sub sites… unable to get any error from iis, uls log.
so we need go to search database to see can get any information.
in this case is we want to see the specify sites after i add the item in , this item going to involved in incremental crawl or not.
normally we can see the item at MSSChangeLogCookies table before the incremental crawl start.
- Run this query: select * from dbo.MSSChangeLogCookies order by UpdateTime desc > you will see all the item change going to crawl
This table keeps track of the last change that the crawler processed for each content database. You'll want to look at the ChangeLogCookie_new column and you'll see several rows but the output of each will look something like this:
1;0;1b82082a-66eb-47bb-a053-26dde844f5ac;634242420353000000;7403
The GUID 1b82082a-66eb-47bb-a053-26dde844f5ac is the content database id
i already have the Database ID on the sites (go to your content DB , check the database information table will know) , so i will search the results and see my database id is available on the MSSChangeLogCookies.
if you want see how many crawl from the content DB you check, you can use below query on the targert content db:
select * from eventcache with (NOLOCK) where ID > '’7403'
so the total row is the item goign to crawl
yeah !! found the item…so go to run the incremental crawl now…but after run also not working!!! ha ha ha…continue checking….DAY 5
here you go for more detail on the .MSSChangeLogCookies :
http://www.cnblogs.com/awpatp/archive/2010/11/02/1866938.html > Chinese version
Monday, November 1, 2010
Crawling history from SSP search DB ( SQL Query)
Copy from MS:
select * from MSSCrawlhistory
select h.crawlid,
c.catalogid,
c.contentsourceid,
c.startaddressid,
typeofcrawl=
case h.crawltype
when 1 then 'full crawl'
when 2 then 'incremental crawl'
end,
h.status as status_id,
status=
case h.status
when 4 then 'start'
when 9 then 'pause'
when 10 then 'resume'
when 13 then 'stop'
when 11 then 'done'
else 'other'
end,
h.requesttime, h.starttime, h.endtime, datediff(n, h.starttime, h.endtime) as 'duration'
from msscrawlhistory h left join msscrawlcontent c
on h.crawlid=c.crawlid where h.projectid=1 order by h.requesttime desc
Tuesday, October 19, 2010
-- Query to get all the SharePoint groups in a site collection
Another cool query from sharepointkings
Customer request the report on all the user in the group on the specify sites collection.
-- Query to get all the SharePoint groups in a site collection
SELECT dbo.Webs.SiteId, dbo.Webs.Id, dbo.Webs.FullUrl, dbo.Webs.Title, dbo.Groups.ID AS Expr1,
dbo.Groups.Title AS Expr2, dbo.Groups.Description
FROM dbo.Groups INNER JOIN
dbo.Webs ON dbo.Groups.SiteId = dbo.Webs.SiteId
-- Query to get all the members of the SharePoint Groups
SELECT dbo.Groups.ID, dbo.Groups.Title, dbo.UserInfo.tp_Title, dbo.UserInfo.tp_Login
FROM dbo.GroupMembership INNER JOIN
dbo.Groups ON dbo.GroupMembership.SiteId = dbo.Groups.SiteId INNER JOIN
dbo.UserInfo ON dbo.GroupMembership.MemberId = dbo.UserInfo.tp_ID
after query the all the memeber of the group, use excel to remove the duplicate data then you will know how many user in the group :)
Wednesday, August 4, 2010
SQL query to find "DayLastAccessed" in portal's Site DB
is time to do clean up for the SharePoint environment , have 2 option i know we can do that. one is manual one is auto :P ha ha ha
Auto one you can setup at CA, Site use confirmation and deletion /_admin/applications.aspx . not sure how correct is it!! ha ha
but i prefer manual one.so use below query to check day last accessed , so we can guess is still used or not.
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
Useful SQL Queries to Analyze and Monitor SharePoint Portal Solutions Usage
keep track on what i can get from internet about SQL query for SharePoint :
i am looking for last access to sites query, but unable to find..but found some other interesting one.. at below from this link
A List of SQL Queries
- Top 100 documents in terms of size (latest version(s) only):
Collapse
SELECT TOP 100 Webs.FullUrl As SiteUrl,
Webs.Title 'Document/List Library Title',
DirName + '/' + LeafName AS 'Document Name',
CAST((CAST(CAST(Size as decimal(10,2))/1024 As
decimal(10,2))/1024) AS Decimal(10,2)) AS 'Size in MB'
FROM Docs INNER JOIN Webs On Docs.WebId = Webs.Id
INNER JOIN Sites ON Webs.SiteId = SItes.Id
WHERE
Docs.Type <> 1 AND (LeafName NOT LIKE '%.stp')
AND (LeafName NOT LIKE '%.aspx')
AND (LeafName NOT LIKE '%.xfp')
AND (LeafName NOT LIKE '%.dwp')
AND (LeafName NOT LIKE '%template%')
AND (LeafName NOT LIKE '%.inf')
AND (LeafName NOT LIKE '%.css')
ORDER BY 'Size in MB' DESC
- Top 100 most versioned documents:
Collapse
SELECT TOP 100
Webs.FullUrl As SiteUrl,
Webs.Title 'Document/List Library Title',
DirName + '/' + LeafName AS 'Document Name',
COUNT(Docversions.version)AS 'Total Version',
SUM(CAST((CAST(CAST(Docversions.Size as decimal(10,2))/1024 As
decimal(10,2))/1024) AS Decimal(10,2)) ) AS 'Total Document Size (MB)',
CAST((CAST(CAST(AVG(Docversions.Size) as decimal(10,2))/1024 As
decimal(10,2))/1024) AS Decimal(10,2)) AS 'Avg Document Size (MB)'
FROM Docs INNER JOIN DocVersions ON Docs.Id = DocVersions.Id
INNER JOIN Webs On Docs.WebId = Webs.Id
INNER JOIN Sites ON Webs.SiteId = SItes.Id
WHERE
Docs.Type <> 1
AND (LeafName NOT LIKE '%.stp')
AND (LeafName NOT LIKE '%.aspx')
AND (LeafName NOT LIKE '%.xfp')
AND (LeafName NOT LIKE '%.dwp')
AND (LeafName NOT LIKE '%template%')
AND (LeafName NOT LIKE '%.inf')
AND (LeafName NOT LIKE '%.css')
GROUP BY Webs.FullUrl, Webs.Title, DirName + '/' + LeafName
ORDER BY 'Total Version' desc, 'Total Document Size (MB)' desc
- List of unhosted pages in the SharePoint solution:
Collapse
select Webs.FullUrl As SiteUrl,
case when [dirname] = ''
then '/'+[leafname]
else '/'+[dirname]+'/'+[leafname]
end as [Page Url],
CAST((CAST(CAST(Size as decimal(10,2))/1024 As
decimal(10,2))/1024) AS Decimal(10,2)) AS 'File Size in MB'
FROM Docs INNER JOIN Webs On Docs.WebId = Webs.Id
where [type]=0
and [leafname] like ('%.aspx')
and [dirname] not like ('%_catalogs/%')
and [dirname] not like ('%/Forms')
and [content] is not null
and [dirname] not like ('%Lists/%')
and [setuppath] is not null
order by [Page Url];
- List of top level WSS sites and their total size, including child sites in the portal:
Collapse
select FullUrl As SiteUrl,
CAST((CAST(CAST(DiskUsed as decimal(10,2))/1024 As
decimal(10,2))/1024) AS Decimal(10,2)) AS 'Total Size in MB'
from sites
Where FullUrl LIKE '%sites%' AND
fullUrl <> 'MySite' AND fullUrl <> 'personal'
- List of portal area and total number of users:
Collapse
select webs.FullUrl, Webs.Title,
COUNT(WebMembers.UserId) As 'Total User'
from Webs INNER JOIN WebMembers
ON Webs.Id = WebMembers.WebId
Where fullurl NOT like '%sites%' AND
fullUrl <> 'MySite' AND fullUrl <> 'personal'
Group BY webs.FullUrl, Webs.Title
Order By 'Total User' desc
- List of top level and sub sites in the portal and the number of users:
Collapse
select webs.FullUrl ,Webs.Title, COUNT(WebMembers.UserId) As 'Total User'
from Webs INNER JOIN WebMembers
ON Webs.Id = WebMembers.WebId
where fullurl like '%sites%' AND fullUrl <> 'MySite' AND fullUrl <> 'personal'
Group BY webs.FullUrl, Webs.Title
Order By 'Total User' desc
- List of all portal area:
Collapse
select Webs.FullUrl As [Site Url],
Title AS [Area Title]
from Webs
Where fullurl NOT like '%sites%' AND fullUrl <>
'MySite' AND fullUrl <> 'personal'
- List of the total portal area:
Collapse
select COUNT(*)from Webs
Where fullurl NOT like '%sites%' AND
fullUrl <> 'MySite' AND fullUrl <> 'personal'
- List of all top level and sub sites in the portal:
Collapse
select Webs.FullUrl As [Site Url],
Title AS [WSS Site Title]
from webs
where fullurl like '%sites%' AND fullUrl <>
'MySite' AND fullUrl <> 'personal'
- List of the total top level and sub sites in the portal:
Collapse
select COUNT(*) from webs
where fullurl like '%sites%' AND fullUrl <>
'MySite' AND fullUrl <> 'personal'
- List of all list/document libraries and total items:
Collapse
select
case when webs.fullurl = ''
then 'Portal Site'
else webs.fullurl
end as [Site Relative Url],
webs.Title As [Site Title],
case tp_servertemplate
when 104 then 'Announcement'
when 105 then 'Contacts'
When 108 then 'Discussion Boards'
when 101 then 'Docuemnt Library'
when 106 then 'Events'
when 100 then 'Generic List'
when 1100 then 'Issue List'
when 103 then 'Links List'
when 109 then 'Image Library'
when 115 then 'InfoPath Form Library'
when 102 then 'Survey'
when 107 then 'Task List'
else 'Other' end as Type,
tp_title 'Title',
tp_description As Description,
tp_itemcount As [Total Item]
from lists inner join webs ON lists.tp_webid = webs.Id
Where tp_servertemplate IN (104,105,108,101,
106,100,1100,103,109,115,102,107,120)
order by tp_itemcount desc
Note: the
tp_servertemplatefield can have the following values:
- 104 = Announcement
- 105 = Contacts List
- 108 = Discussion Boards
- 101 = Document Library
- 106 = Events
- 100 = Generic List
- 1100 = Issue List
- 103 = Links List
- 109 = Image Library
- 115 = InfoPath Form Library
- 102 = Survey List
- 107 = Task List
- List of document libraries and total items:
Collapse
select
case when webs.fullurl = ''
then 'Portal Site'
else webs.fullurl
end as [Site Relative Url],
webs.Title As [Site Title],
lists.tp_title As Title,
tp_description As Description,
tp_itemcount As [Total Item]
from lists inner join webs ON lists.tp_webid = webs.Id
Where tp_servertemplate = 101
order by tp_itemcount desc
- List of image libraries and total items:
Collapse
select case when webs.fullurl = ''
then 'Portal Site'
else webs.fullurl
end as [Site Relative Url],
webs.Title As [Site Title],
lists.tp_title As Title,
tp_description As Description,
tp_itemcount As [Total Item]
from lists inner join webs ON lists.tp_webid = webs.Id
Where tp_servertemplate = 109 -- Image Library
order by tp_itemcount desc
- List of announcement list and total items:
Collapse
select case when webs.fullurl = ''
then 'Portal Site'
else webs.fullurl
end as [Site Relative Url],
webs.Title As [Site Title],
lists.tp_title As Title,
tp_description As Description,
tp_itemcount As [Total Item]
from lists inner join webs ON lists.tp_webid = webs.Id
Where tp_servertemplate = 104 -- Announcement List
order by tp_itemcount desc
- List of contact list and total items:
Collapse
select case when webs.fullurl = ''
then 'Portal Site'
else webs.fullurl
end as [Site Relative Url],
webs.Title As [Site Title],
lists.tp_title As Title,
tp_description As Description,
tp_itemcount As [Total Item]
from lists inner join webs ON lists.tp_webid = webs.Id
Where tp_servertemplate = 105 -- Contact List
order by tp_itemcount desc
- List of event list and total items:
Collapse
select case when webs.fullurl = ''
then 'Portal Site'
else webs.fullurl
end as [Site Relative Url],
webs.Title As [Site Title],
lists.tp_title As Title,
tp_description As Description,
tp_itemcount As [Total Item]
from lists inner join webs ON lists.tp_webid = webs.Id
Where tp_servertemplate = 106 -- Event List
order by tp_itemcount desc
- List of all tasks and total items:
Collapse
select
case when webs.fullurl = ''
then 'Portal Site'
else webs.fullurl
end as [Site Relative Url],
webs.Title As [Site Title],
lists.tp_title As Title,
tp_description As Description,
tp_itemcount As [Total Item]
from lists inner join webs ON lists.tp_webid = webs.Id
Where tp_servertemplate = 107 -- Task List
order by tp_itemcount desc
- List of all InfoPath form library and total items:
Collapse
select
case when webs.fullurl = ''
then 'Portal Site'
else webs.fullurl
end as [Site Relative Url],
webs.Title As [Site Title],
lists.tp_title As Title,
tp_description As Description,
tp_itemcount As [Total Item]
from lists inner join webs ON lists.tp_webid = webs.Id
Where tp_servertemplate = 115 -- Infopath Library
order by tp_itemcount desc
- List of generic list and total items:
Collapse
select
case when webs.fullurl = ''
then 'Portal Site'
else webs.fullurl
end as [Site Relative Url],
webs.Title As [Site Title],
lists.tp_title As Title,
tp_description As Description,
tp_itemcount As [Total Item]
from lists inner join webs ON lists.tp_webid = webs.Id
Where tp_servertemplate = 100 -- Generic List
order by tp_itemcount desc
- Total number of documents:
Collapse
SELECT COUNT(*)
FROM Docs INNER JOIN Webs On Docs.WebId = Webs.Id
INNER JOIN Sites ON Webs.SiteId = SItes.Id
WHERE
Docs.Type <> 1 AND (LeafName NOT LIKE '%.stp')
AND (LeafName NOT LIKE '%.aspx')
AND (LeafName NOT LIKE '%.xfp')
AND (LeafName NOT LIKE '%.dwp')
AND (LeafName NOT LIKE '%template%')
AND (LeafName NOT LIKE '%.inf')
AND (LeafName NOT LIKE '%.css')
- Total MS Word documents:
Collapse
SELECT count(*)
FROM Docs INNER JOIN Webs On Docs.WebId = Webs.Id
INNER JOIN Sites ON Webs.SiteId = SItes.Id
WHERE
Docs.Type <> 1 AND (LeafName LIKE '%.doc')
AND (LeafName NOT LIKE '%template%')
- Total MS Excel documents:
Collapse
SELECT count(*)
FROM Docs INNER JOIN Webs On Docs.WebId = Webs.Id
INNER JOIN Sites ON Webs.SiteId = SItes.Id
WHERE
Docs.Type <> 1 AND (LeafName LIKE '%.xls')
AND (LeafName NOT LIKE '%template%')
- Total MS PowerPoint documents:
Collapse
SELECT count(*)
FROM Docs INNER JOIN Webs On Docs.WebId = Webs.Id
INNER JOIN Sites ON Webs.SiteId = SItes.Id
WHERE
Docs.Type <> 1 AND (LeafName LIKE '%.ppt')
AND (LeafName NOT LIKE '%template%')
- Total TXT documents:
Collapse
SELECT count(*)
FROM Docs INNER JOIN Webs On Docs.WebId = Webs.Id
INNER JOIN Sites ON Webs.SiteId = SItes.Id
WHERE
Docs.Type <> 1 AND (LeafName LIKE '%.txt')
AND (LeafName NOT LIKE '%template%')
- Total Zip files:
Collapse
SELECT count(*)
FROM Docs INNER JOIN Webs On Docs.WebId = Webs.Id
INNER JOIN Sites ON Webs.SiteId = SItes.Id
WHERE
Docs.Type <> 1 AND (LeafName LIKE '%.zip')
AND (LeafName NOT LIKE '%template%')
- Total PDF files:
Collapse
SELECT count(*)
FROM Docs INNER JOIN Webs On Docs.WebId = Webs.Id
INNER JOIN Sites ON Webs.SiteId = SItes.Id
WHERE
Docs.Type <> 1 AND (LeafName LIKE '%.pdf')
AND (LeafName NOT LIKE '%template%')
- Total JPG files:
Collapse
SELECT count(*)
FROM Docs INNER JOIN Webs On Docs.WebId = Webs.Id
INNER JOIN Sites ON Webs.SiteId = SItes.Id
WHERE
Docs.Type <> 1 AND (LeafName LIKE '%.jpg')
AND (LeafName NOT LIKE '%template%')
- Total GIF files:
Collapse
SELECT count(*)
FROM Docs INNER JOIN Webs On Docs.WebId = Webs.Id
INNER JOIN Sites ON Webs.SiteId = SItes.Id
WHERE
Docs.Type <> 1 AND (LeafName LIKE '%.gif')
AND (LeafName NOT LIKE '%template%')
- Total files other than DOC, PDF, XLS, PPT, TXT, Zip, ASPX, DEWP, STP, CSS, JPG, GIF:
Collapse
SELECT count(*)
FROM Docs INNER JOIN Webs On Docs.WebId = Webs.Id
INNER JOIN Sites ON Webs.SiteId = SItes.Id
WHERE
Docs.Type <> 1 AND (LeafName NOT LIKE '%.pdf')
AND (LeafName NOT LIKE '%template%')
AND (LeafName NOT LIKE '%.doc')
AND (LeafName NOT LIKE '%.xls')
AND (LeafName NOT LIKE '%.ppt')
AND (LeafName NOT LIKE '%.txt')
AND (LeafName NOT LIKE '%.zip')
AND (LeafName NOT LIKE '%.aspx')
AND (LeafName NOT LIKE '%.dwp')
AND (LeafName NOT LIKE '%.stp')
AND (LeafName NOT LIKE '%.css')
AND (LeafName NOT LIKE '%.jpg')
AND (LeafName NOT LIKE '%.gif')
AND (LeafName <>'_webpartpage.htm')
- Total size of all documents:
Collapse
SELECT SUM(CAST((CAST(CAST(Size as decimal(10,2))/1024
As decimal(10,2))/1024) AS Decimal(10,2)))
AS 'Total Size in MB'
FROM Docs INNER JOIN Webs On Docs.WebId = Webs.Id
INNER JOIN Sites ON Webs.SiteId = SItes.Id
WHERE
Docs.Type <> 1 AND (LeafName NOT LIKE '%.stp')
AND (LeafName NOT LIKE '%.aspx')
AND (LeafName NOT LIKE '%.xfp')
AND (LeafName NOT LIKE '%.dwp')
AND (LeafName NOT LIKE '%template%')
AND (LeafName NOT LIKE '%.inf')
AND (LeafName NOT LIKE '%.css')
AND (LeafName <>'_webpartpage.htm')
