[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

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

Posted on 2012-08-15
2
Medium Priority
?
769 Views
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:

WHERE
  CONTAINS(fullTextCol,''@fullText'')

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.
0
Comment
Question by:sqlagent007
2 Comments
 
LVL 75

Accepted Solution

by:
Anthony Perkins earned 2000 total points
ID: 38298707
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"'

WHERE
  CONTAINS(fullTextCol,  @fullText)
0
 
LVL 1

Author Closing Comment

by:sqlagent007
ID: 38309837
Thanks!
0

Featured Post

Restore individual SQL databases with ease

Veeam Explorer for Microsoft SQL Server delivers an easy-to-use, wizard-driven interface for restoring your databases from a backup. No expert SQL background required. Web interface provides a complete view of all available SQL databases to simplify the recovery of lost database

Question has a verified solution.

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

A Stored Procedure in Microsoft SQL Server is a powerful feature that it can be used to execute the Data Manipulation Language (DML) or Data Definition Language (DDL). Depending on business requirements, a single Stored Procedure can return differe…
It is possible to export the data of a SQL Table in SSMS and generate INSERT statements. It's neatly tucked away in the generate scripts option of a database.
Via a live example, show how to shrink a transaction log file down to a reasonable size.
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.
Suggested Courses

829 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