Solved

Full Text Search CONTAINS error on column list - MS SQL 2000

Posted on 2008-10-17
5
604 Views
Last Modified: 2012-05-05
I am working on a full text search query and am receiving the following error:

Line 8: Incorrect Syntax Near '('

Line 8 is as follows:
CONTAINSTABLE (Product, (Product_Name,Product_Desc,Product_ManufacturerPart,UPC,Manufacturer_Name,Searchable_Terms,Book_Author,Book_Type), '(Cannon NEAR digital NEAR rebel)', 10) AS KEY_TBL

The issue is with the column list:
(Product_Name,Product_Desc,Product_ManufacturerPart,UPC,Manufacturer_Name,Searchable_Terms,Book_Author,Book_Type)

When I replace this column list with an asterisk (*), the query works fine.

From MSDN.com:
column_list
    Indicates that several columns, separated by a comma, can be specified. column_list must be enclosed in parentheses. Unless language_term is specified, the language of all columns of column_list must be the same.

I am conforming to this - why am I getting an error?
SELECT 
    FT_TBL.Product_Name, 
    FT_TBL.Product_Desc, 
    KEY_TBL.RANK
FROM 
    production.dbo.product AS FT_TBL 
    INNER JOIN
        CONTAINSTABLE (Product, (Product_Name,Product_Desc,Product_ManufacturerPart,UPC,Manufacturer_Name,Searchable_Terms,Book_Author,Book_Type), '(Cannon NEAR digital NEAR rebel)', 10) AS KEY_TBL
        ON FT_TBL.Product_ID = KEY_TBL.[KEY]

Open in new window

0
Comment
Question by:trickyidiot
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 143

Assisted Solution

by:Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3] earned 150 total points
ID: 22744824
please refer to the sql 2000 version of the syntax:
http://msdn.microsoft.com/en-us/library/aa258229(SQL.80).aspx
which does NOT have the (columnlist) variant of the syntax

the sql 2005/2008 versions do have that variant:
sql 2005:
http://msdn.microsoft.com/en-us/library/ms189760(SQL.90).aspx
sql 2008:
msdn.microsoft.com/en-us/library/ms189760.aspx

so, if you are indeed on sql 2000, you cannot use that syntax.
0
 
LVL 39

Assisted Solution

by:BrandonGalderisi
BrandonGalderisi earned 350 total points
ID: 22744838
0
 
LVL 6

Author Comment

by:trickyidiot
ID: 22744983
Ok - I've moved to a less tempting solution, listed below

but I'm getting the same error - incorrect syntax near ')'
on the last line of the query
select 
    * 
from 
    product 
where 
    product_id in 
    (
        select distinct 
            p.product_id 
        from 
        (
            SELECT 
                p.product_id  
            FROM 
                product AS P 
                INNER JOIN 
                    CONTAINSTABLE(Product, Product_Name, 'cannon NEAR battery') AS KEY_TBL
                    ON p.Product_ID = KEY_TBL.[KEY] 
 
            UNION ALL
 
            SELECT 
                p.product_id  
            FROM 
                product AS P 
                INNER JOIN 
                    CONTAINSTABLE(Product, Product_Desc, 'cannon NEAR battery') AS KEY_TBL
                    ON p.Product_ID = KEY_TBL.[KEY] 
 
            UNION ALL
 
            SELECT 
                p.product_id  
            FROM 
                product AS P 
                INNER JOIN 
                    CONTAINSTABLE(Product, Product_ManufacturerPart, 'cannon NEAR battery') AS KEY_TBL
                    ON p.Product_ID = KEY_TBL.[KEY] 
 
            UNION ALL
 
            SELECT 
                p.product_id  
            FROM 
                product AS P 
                INNER JOIN 
                    CONTAINSTABLE(Product, UPC, 'cannon NEAR battery') AS KEY_TBL
                    ON p.Product_ID = KEY_TBL.[KEY] 
 
            UNION ALL
 
            SELECT 
                p.product_id  
            FROM 
                product AS P 
                INNER JOIN 
                    CONTAINSTABLE(Product, Manufacturer_Name, 'cannon NEAR battery') AS KEY_TBL
                    ON p.Product_ID = KEY_TBL.[KEY] 
 
            UNION ALL
 
            SELECT 
                p.product_id  
            FROM 
                product AS P 
                INNER JOIN 
                    CONTAINSTABLE(Product, Searchable_Terms, 'cannon NEAR battery') AS KEY_TBL
                    ON p.Product_ID = KEY_TBL.[KEY] 
            UNION ALL
 
            SELECT 
                p.product_id  
            FROM 
                product AS P 
                INNER JOIN 
                    CONTAINSTABLE(Product, Book_Author, 'cannon NEAR battery') AS KEY_TBL
                    ON p.Product_ID = KEY_TBL.[KEY] 
 
            UNION ALL
 
            SELECT 
                p.product_id  
            FROM 
                product AS P 
                INNER JOIN 
                    CONTAINSTABLE(Product, Book_Type, 'cannon NEAR battery') AS KEY_TBL
                    ON p.Product_ID = KEY_TBL.[KEY] 
        )
    )

Open in new window

0
 
LVL 39

Accepted Solution

by:
BrandonGalderisi earned 350 total points
ID: 22745001
The problem now is that you aren't naming your derived table.  I added b to the next to the last line.
select 
    * 
from 
    product 
where 
    product_id in 
    (
        select distinct 
            p.product_id 
        from 
        (
            SELECT 
                p.product_id  
            FROM 
                product AS P 
                INNER JOIN 
                    CONTAINSTABLE(Product, Product_Name, 'cannon NEAR battery') AS KEY_TBL
                    ON p.Product_ID = KEY_TBL.[KEY] 
 
            UNION ALL
 
            SELECT 
                p.product_id  
            FROM 
                product AS P 
                INNER JOIN 
                    CONTAINSTABLE(Product, Product_Desc, 'cannon NEAR battery') AS KEY_TBL
                    ON p.Product_ID = KEY_TBL.[KEY] 
 
            UNION ALL
 
            SELECT 
                p.product_id  
            FROM 
                product AS P 
                INNER JOIN 
                    CONTAINSTABLE(Product, Product_ManufacturerPart, 'cannon NEAR battery') AS KEY_TBL
                    ON p.Product_ID = KEY_TBL.[KEY] 
 
            UNION ALL
 
            SELECT 
                p.product_id  
            FROM 
                product AS P 
                INNER JOIN 
                    CONTAINSTABLE(Product, UPC, 'cannon NEAR battery') AS KEY_TBL
                    ON p.Product_ID = KEY_TBL.[KEY] 
 
            UNION ALL
 
            SELECT 
                p.product_id  
            FROM 
                product AS P 
                INNER JOIN 
                    CONTAINSTABLE(Product, Manufacturer_Name, 'cannon NEAR battery') AS KEY_TBL
                    ON p.Product_ID = KEY_TBL.[KEY] 
 
            UNION ALL
 
            SELECT 
                p.product_id  
            FROM 
                product AS P 
                INNER JOIN 
                    CONTAINSTABLE(Product, Searchable_Terms, 'cannon NEAR battery') AS KEY_TBL
                    ON p.Product_ID = KEY_TBL.[KEY] 
            UNION ALL
 
            SELECT 
                p.product_id  
            FROM 
                product AS P 
                INNER JOIN 
                    CONTAINSTABLE(Product, Book_Author, 'cannon NEAR battery') AS KEY_TBL
                    ON p.Product_ID = KEY_TBL.[KEY] 
 
            UNION ALL
 
            SELECT 
                p.product_id  
            FROM 
                product AS P 
                INNER JOIN 
                    CONTAINSTABLE(Product, Book_Type, 'cannon NEAR battery') AS KEY_TBL
                    ON p.Product_ID = KEY_TBL.[KEY] 
        ) b
    ) 

Open in new window

0
 
LVL 6

Author Closing Comment

by:trickyidiot
ID: 31507281
Thanks guys!

I didn't even realize I was reading the wrong doc on msdn...
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

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

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Logical Operator should return Integer value in SSIS 9 37
Need help with a query 14 39
access to sql migration 5 24
Need multiple Group By's 8 27
Confronted with some SQL you don't know can be a daunting task. It can be even more daunting if that SQL carries some of the old secret codes used in the Ye Olde query syntax, such as: (+)     as used in Oracle;     *=     =*    as used in Sybase …
Composite queries are used to retrieve the results from joining multiple queries after applying any filters. UNION, INTERSECT, MINUS, and UNION ALL are some of the operators used to get certain desired results.​
Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.
Via a live example, show how to shrink a transaction log file down to a reasonable size.

733 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question