Order by Relevance

First off, sorry. 45 points is all the points I have left. :(

One of my tables has 3 text columns. I'm searching these three columns for words. I want to order the results by the total number of words found in all three columns combined.

Is it possible? I don't want to use VBScript to reorder them, especially if I have 1000 results.

Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

jdlambert1Connect With a Mentor Commented:
No, no, ContainsTable is your best solution, and it's part of SQL Server. I wasn't going to post anything, since it looked like you were on the right track, and you could delete the question and save your points if you finished on your own.

Run "sp_fulltext_database enable" to turn on full-text indexing on the database.

If you get an error message it's probably because full-text indexing wasn't installed. Put in your CD and start the install process, and choose "Upgrade, remove, or add components to an existing instance of SQL Server." when it gives you that choice. Then in the Select Components window, select Server Component on the left, then check "Full-Text Search" on the right.

Once it's installed and the database is enabled, you have to enable the table:
sp_fulltext_table [ @tabname = ] 'qualified_table_name'
    , [ @action = ] 'action'
    [ , [ @ftcat = ] 'fulltext_catalog_name'
    , [ @keyname = ] 'unique_index_name' ]

Once you have the table enabled, you have to enable each of the three columns you want to use for your relevance ranking.

Then you can write a SELECT query with a ContainsTable clause.

See SQL Server Books Online (BOL) for sample code and more info.
nightzeusAuthor Commented:
nightzeusAuthor Commented:
Nevermind.. It seems to be part of another Microsoft program.

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

nightzeusAuthor Commented:
Thank you. :)
You're welcome. I forgot to post the procedure for enabling columns:

sp_fulltext_column [ @tabname = ] 'qualified_table_name' ,
    [ @colname = ] 'column_name' ,
    [ @action = ] 'action'
    [ , [ @language = ] 'language' ]
    [ , [ @type_colname = ] 'type_column_name' ]
nightzeusAuthor Commented:
:))) Thanks again.

All Courses

From novice to tech pro — start learning today.