MOSS 2007 Enterprise search example SQL queries
By peter.stilgoe
Finds relevant results containing the keyword SharePoint.
SELECT WorkId,Path,Title,Write,Author,HitHighlightedSummary, HitHighlightedProperties,CollapsingStatusFROM Scope()WHERE FREETEXT(defaultproperties, ‘SharePoint’) ORDER BY Rank DescFinds relevant results containing at least one of the keywords SharePoint and Search.
SELECT WorkId,Path,Title,Write,Author,…FROM Scope()WHERE FREETEXT(defaultproperties, ‘SharePoint Search’) ORDER BY Rank DescFinds relevant results containing both the keywords SharePoint and Search.
SELECT WorkId,Path,Title,Write,Author,…FROM Scope()WHERE FREETEXT(defaultproperties, ‘+SharePoint +Search’) ORDER BY Rank DescFinds relevant results containing the exact phrase SharePoint Search.
SELECT WorkId,Path,Title,Write,Author,…FROM Scope()WHERE FREETEXT(defaultproperties, ‘ “SharePoint Search” ‘) ORDER BY Rank DescFinds relevant results containing both the keywords SharePoint and Search but not the keyword WSS.
SELECT WorkId,Path,Title,Write,Author,…FROM Scope()WHERE FREETEXT(defaultproperties, ‘+SharePoint +Search -WSS’) ORDER BY Rank DescFinds relevant SharePoint results authored by persons named John.
SELECT WorkId,Path,Title,Write,Author,…FROM Scope()WHERE FREETEXT(defaultproperties, ‘SharePoint’) AND CONTAINS(Author,’ “John” ‘)ORDER BY Rank DescFinds relevant SharePoint results modified within the last 30 days.
SELECT WorkId,Path,Title,Write,Author,…FROM Scope()WHERE FREETEXT(defaultproperties, ‘SharePoint’) AND Write<=DATEADD(DAY,30,GETGMTDATE())ORDER BY Rank Desc
More From pstilgoe



October 20th, 2008
