which country user step here?

Tag Cloud

MOSS (47) SharePoint 2007 (37) SharePoint 2013 (31) SharePoint 2010 (23) MOSS admin (17) PowerShell (17) admin (17) developer (16) List (15) WSS (14) sql query (14) MOSS SP2 (13) end user (11) scripting (11) wss V3 (11) permission (10) sql (9) Moss issue (8) search (8) database (7) RBS (6) Service Pack (6) reportadmin (6) workflow (6) CU (5) Excel (5) Patch (5) client object model (5) Client Code (4) Command (4) Cumulative Updates (4) IIS (4) SharePoint 2019 (4) SharePoint designer (4) office 365 (4) stsadm (4) user porfile (4) ASP.NET (3) Content Database (3) Groove (3) Host Named Site Collections (HNSC) (3) SharePoint 2016 (3) Tutorial (3) alert (3) authentication (3) batch file (3) codeplex (3) domain (3) error (3) incomming email (3) issue (3) restore (3) upload (3) Caching (2) DocAve 6 (2) Folder (2) Index (2) Internet (2) My Site Cleanup Job (2) My Sites (2) News (2) People Picker (2) Share Document (2) SharePoint admin (2) View (2) Web Development with ASP.NET (2) add user (2) audit (2) coding (2) column (2) deploy solution (2) download (2) enumsites (2) exam (2) export (2) june CU (2) load balance (2) mySites (2) network (2) orphan site (2) performance (2) profile (2) project server (2) query (2) security (2) server admin (2) theme (2) timer job (2) training (2) web master (2) web.config (2) wsp (2) 70-346 (1) 70-630 (1) AAM (1) Anonymous (1) Approval (1) AvePoint (1) Cerificate (1) Consultants (1) Content Deployment (1) Content Type (1) DOS (1) Document Library (1) Drive Sapce (1) Excel Services (1) Export to Excel (1) Feature (1) GAC (1) Get-SPContentDatabase (1) Get-WmiObject (1) HTML calculated column (1) ISA2006 (1) IT Knowledge (1) ITIL (1) Install (1) Link (1) MCTS (1) Macro (1) Masking (1) Migration (1) NLBS (1) Nintex (1) Office (1) Open with Explorer (1) ROIScan.vbs (1) Reporting Services (1) SPDisposeCheck.exe (1) SQL Instance name (1) SSRS (1) Sandbox (1) SharePoint Online (1) SharePoint farm (1) Shared Services Administration (1) Site Collection Owner (1) Site template (1) Skype for business (1) Steelhead (1) Teams (1) URLSCAN (1) VLOOKUP (1) WSS SP2 (1) XCOPY (1) abnormal incident (1) admi (1) app (1) application pool (1) aspx (1) availabilty (1) backup (1) binding (1) blob (1) branding sharepoint (1) cache (1) calendar (1) change password (1) connection (1) copy file (1) counter (1) crawl (1) custom list (1) domain security group (1) event (1) excel 2013 (1) facebook (1) filter (1) fun (1) group (1) iis log (1) import (1) import list (1) improment (1) interview (1) keberos (1) licensing (1) log in (1) metada (1) migrate (1) mossrap (1) notepad++ (1) onedrive for business (1) operation (1) owa (1) process (1) publishing feature (1) resource (1) send email (1) size (1) sps2003 (1) sql201 (1) sql2012 (1) sub sites (1) system (1) table (1) task list (1) today date (1) trial (1) vbs (1) video (1) web part (1) web server (1) widget (1) windows 2008 (1) windows 2012 R2 (1) windows Azura (1) windows account (1) windows2012 (1) wmi (1)
Showing posts with label sql query. Show all posts
Showing posts with label sql query. Show all posts

Monday, June 5, 2017

SQL script add user to all content database

SET NOCOUNT ON;

DECLARE @user_name    SYSNAME
        , @login_name SYSNAME;

SELECT @user_name = ‘Domain\Account’,
       @login_name = ‘Domain\Account’

SELECT '
    USE ' + QUOTENAME(NAME) + '
CREATE USER ' + QUOTENAME(@user_name)
       + '
    ALTER ROLE [db_owner] ADD MEMBER [Domain\Account]
    GO
 
'
FROM   sys.databases
WHERE  database_id > 4

       AND state_desc = 'ONLINE'

---------------------------------------------------------------------------------------------------

  • execute the results to text then can copy and paste to run it 
  • excluded the system database



Saturday, May 7, 2016

SQL query : Shrink SQL log file

use content_database_name
ALTER DATABASE content_database_name SET RECOVERY SIMPLE
DBCC SHRINKFILE(content_database_name_log )

ALTER DATABASE content_database_name SET RECOVERY FULL

Sql query check instance name and sever name

SELECT @@servicename AS Servicename --returns instance name, even if this is the default (MSSQLSERVER)
SELECT SERVERPROPERTY ('InstanceName') AS InstanceName --null mean is defalut

select @@SERVERNAME AS SQLclusterName
SELECT   CONVERT(char(20), SERVERPROPERTY('servername'))AS WindowsClusterName --use this name to connect to db

SELECT @@SERVERNAME  AS pre_change_name, --returns servername\instance as far as this is not the default instance

 Serverproperty('Servername') AS current_server_name 

Friday, April 1, 2016

SharePoint 2013 RBS setup for second content database

Normally you can get the information from internet for first time RBS setup step , example : https://blogs.technet.microsoft.com/bogdang/2014/12/04/install-and-configure-rbs-with-sharepoint-2013-and-sql-server-2012/

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

SELECT r.session_id,command,
            s.text,
            start_time,
            percent_complete,
            CAST(((DATEDIFF(s,start_time,GetDate()))/3600) as varchar) + ' hour(s), '
                  + CAST((DATEDIFF(s,start_time,GetDate())%3600)/60 as varchar) + 'min, '
                  + CAST((DATEDIFF(s,start_time,GetDate())%60) as varchar) + ' sec' as running_time,
            CAST((estimated_completion_time/3600000) as varchar) + ' hour(s), '
                  + CAST((estimated_completion_time %3600000)/60000 as varchar) + 'min, '
                  + CAST((estimated_completion_time %60000)/1000 as varchar) + ' sec' as est_time_to_go,
            dateadd(second,estimated_completion_time/1000, getdate()) as est_completion_time
FROM sys.dm_exec_requests r
CROSS APPLY sys.dm_exec_sql_text(r.sql_handle) s
WHERE r.command in ('RESTORE DATABASE', 'BACKUP DATABASE', 'RESTORE LOG', 'BACKUP LOG')

Kill the process
Kill

KILL 1866 WITH STATUSONLY >> check the status on this progress

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

jdoe@acmedomain.com

14

HR Team Member

20

Doe, Jane

acmedomain\jadoe

jadoe@acmedomain.com

14

HR Team Member

2

Smith, Bob

acmedomain\bsmith

bsmith@acmedomain.com

14

HR Team Member

24

Yamamoto, Kazue

acmedomain\kyamamoto

kyamamoto@acmedomain.com

14

HR Team Member

46

Nakamura, Ichiro

acmedomain\inakamura

inakamura@acmedomain.com

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

jdoe@acmedomain.com

14

HR Team Member

20

Doe, Jane

acmedomain\jadoe

jadoe@acmedomain.com

14

HR Team Member

2

Smith, Bob

acmedomain\bsmith

bsmith@acmedomain.com

14

HR Team Member

24

Yamamoto, Kazue

acmedomain\kyamamoto

kyamamoto@acmedomain.com

14

HR Team Member

46

Nakamura, Ichiro

acmedomain\inakamura

inakamura@acmedomain.com

14

HR Team Member

7

Horowitz, Rick

acmedomain\rhorowitz

rhorowitz@acmedomain.com

15

Acct Sr Managers

3

Davis, Jiro

acmedomain\jdavis

jdavis@acmedomain.com

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.

 

  1. 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://blogs.msdn.com/b/russmax/archive/2008/11/17/how-to-determine-the-number-of-changes-an-incremental-crawl-will-process-prior-to-initiating-the-crawl.aspx

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_servertemplate field 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')