I am getting following error in my SQL server 2008 R2 database:
Cannot use a
CONTAINS
orFREETEXT
predicate on table or indexed view 'tblArmy' because it is not full-text indexed.
This question is related to
sql
sql-server
tsql
sql-server-2008
full-text-search
You must define Full-Text-Index
on all tables in database where you require to use a query with CONTAINS
which will take sometime.
Instead you can use the LIKE
which will give you instant results without the need to adjust any settings for the tables.
Example:
SELECT * FROM ChartOfAccounts WHERE AccountName LIKE '%Tax%'
The same result obtained with CONTAINS
can be obtained with LIKE
.
A workaround for CONTAINS
: If you don't want to create a full text Index on the column, and performance is not one of your priorities you could use the LIKE
statement which doesn't need any prior configuration:
Example: find all Products that contains the letter Q:
SELECT ID, ProductName
FROM [ProductsDB].[dbo].[Products]
WHERE [ProductsDB].[dbo].[Products].ProductName LIKE '%Q%'
You might need to enable the table for full-text indexing.
There is one more solution to set column Full text to true.
These solution for example didn't work for me
ALTER TABLE news ADD FULLTEXT(headline, story);
My solution.
NEXT STEPS
Refresh
Version of mssql 2014
Select * from table
where CONTAINS([Column], '"A00*"')
will act as % same as
where [Column] Like 'A00%'
you have to add fulltext index on specific fields you want to search.
ALTER TABLE news ADD FULLTEXT(headline, story);
where "news" is your table and "headline, story" fields you wont to enable for fulltext search
Source: Stackoverflow.com