Home About Us Services Experience Technology Resources Careers News Contact Us
Mission and Values
Leadership Team
Certifications
Capability Statement
Consulting
Development
Turnarounds
Support
Success Stories
Presentations
Publications
Awards
EDI
RFID
Extranet
Voice and Speech
Natural Language
Handheld and Mobile
Articles and Reference
Code Samples
Downloads
Regular Reading
Email Subscriptions
Services Recommendations
Software Recommendations
Current Opportunities
Careers for Developers
SQL Server Code Samples
Full-Text Queries with CONTAINS  |  List Number of Rows in Each Table
How Long has SQL Server been Running?  | 


Full-Text Queries with CONTAINS
SQL Server provides the Contains clause for performing a variety of text searches. Using the Contains clause provides search results and the rank of the result based on the query.
  • To look for a word in a table by searching every column:
    SELECT * FROM TABLE1 WHERE CONTAINS(*, 'word')
    
  • To look for a wildcard, use * as follows:
    SELECT * FROM TABLE1 WHERE CONTAINS(*, '"word*"')
    
  • To find a word near another word, use NEAR:
    SELECT * FROM TABLE1 WHERE CONTAINS(*, 'word' NEAR 'another')
    
  • To get verb changes, use FORMSOF and INFLECTIONAL. For example, to search on waste and get wasting, use:
    SELECT * FROM TABLE1 WHERE CONTAINS(*, 'FORMSOF(INFLECTIONAL, waste)')
    
  • To get hits above a certain weight--say, .7--use:
    SELECT * FROM TABLE1 WHERE CONTAINS(*,'word' NEAR 'another' WEIGHT(.7))
    
As you can see, this is a very powerful clause to consider when performing text searches. It should be noted, however, that the clause is not transportable to other databases.
 
List Number of Rows in Each Table
SELECT Object_Name(SysObjects.ID) TableName, Rows, DPages
   FROM SysIndexes, SysObjects
   WHERE SysIndexes.ID = SysObjects.ID AND
         SysObjects.Type = 'U' AND
         SysIndexes.IndID IN (0, 1)
   ORDER BY Rows DESC
How Long has SQL Server been Running?
SELECT Login_Time FROM Master..SysProcesses WHERE SPID = 1
© The Intellection Group, Inc.  All Rights Reserved
Privacy Statement    Disclaimer