SQL 2005 full-text search use a @variable with CONTAINS?

Posted on 2012-08-15
Last Modified: 2012-08-19
I am trying to build a stored proc that takes varchar input and uses that in the CONTAINS part of the query.

Something like this:


When I try this, both with ''+@fullText+'', also with ''''@fullText'''', I get an error saying incorrect syntax near CONTAINS.

I am using SQL 2005 standard edition.
Question by:sqlagent007
    LVL 75

    Accepted Solution

    I think we already covered this in your other question, but here it goes again:

    DECLARE @fullText varchar(100)
    Set @fullText = '"This is where your phrase goes"'

      CONTAINS(fullTextCol,  @fullText)
    LVL 1

    Author Closing Comment


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
    Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
    Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
    Via a live example combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL Server.

    779 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

    Need Help in Real-Time?

    Connect with top rated Experts

    10 Experts available now in Live!

    Get 1:1 Help Now