SQL Server 2008 - Full Text Query

Posted by user208662 on Stack Overflow See other posts from Stack Overflow or by user208662
Published on 2010-05-03T12:50:28Z Indexed on 2010/05/03 13:08 UTC
Read the original article Hit count: 215

Filed under:
|

Hello,

I have two tables in a SQL Server 2008 database in my company. The first table represents the products that my company sells. The second table contains the product manufacturer’s details. These tables are defined as follows:

  Product
  -------
  ID
  Name
  ManufacturerID
  Description

  Manufacturer
  ------------
  ID
  Name

As you can imagine, I want to make this as easy as possible for our customers to query this data. However, I’m having problems writing a forgiving, yet powerful search query. For instance, I’m anticipating people to search based on phonetical spellings. Because of this, the data may not match the exact data in my database. In addition, I think some individuals will search by manufacturer’s name first, but I want the matching product names to appear first. Based on these requirements, I’m currently working on the following query:

  select
    p.Name as 'ProductName',
    m.Name as 'Manufacturer',
    r.Rank as 'Rank'
  from
    Product p inner join Manufacturer m on p.ManufacturerID=m.ID
      inner join CONTAINSTABLE(Product, Name, @searchQuery) as r

Oddly, this query is throwing an error. However, I have no idea why. Squiggles appear to the right of the last parenthesis in management studio. The tool tip says "An expression of non-boolean type specified in a context where a condition is expected". I understand what this statement means. However, I guess I do not know how COntainsTable works. What am I doing wrong?

Thank you

© Stack Overflow or respective owner

Related posts about sql

Related posts about sql-server-2008