Creating FullText Index in SQL Server :
In this article I'm trying to explain how to create FullText Index in SQL servers, using this we can able to search multiple matched text while searching data. We all are know that we can able to search single text using like keyword but we can't fetch multiple text search using like keyword for that we go to freetext search in SQL servers.
Freetext search in SQL server is one of the great features to give multiple search resulted data. But without creating FULLTEXT if you try to use FreeText then it will throw error.
"Cannot use a CONTAINS or FREETEXT predicate on table or indexed view 'Search' because it is not full-text indexed."
To overcome the above issue we must create FULLTEXT catalog, after that using that table constraint name we can able to create FULLTEXT INDEX. Once FULLTEXT INDEX has been created for that particular table then you can able to search multiple texts.
You can achieve this by follow the below steps.
Create a table like below in your database.
create table Search
id int primary key identity(1,1),
Create FULLTEXT catalog in your database. Use below query for creating FULLTEXT CATALOG.
CREATE FULLTEXT CATALOG FULLTEXTSearch
After create catalog in your database, then find the constraint name of that particular table using below query.
SELECT * FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS where TABLE_NAME ='search'
Now this is the time to create FULLTEXT INDEX, for this we must and should have a key index. Using that key index of the table we can able to create FULLTEXT INDEX for that particular table.
CREATE FULLTEXT INDEX ON Search
([name] LANGUAGE 1033)
KEY INDEX PK__Search__3213E83FED0050D2
Note: keep in mind we can able to create FULLTEXT INDEX for only Primary Key and Unique key containing tables only.
Now you can able to search multiple search strings using "freetext" search in sql servers.
Refer below sample for that.
insert into Search ( name)
select * from Search where freetext(name,'James John Sam')
This article will help you to search multiple strings while searching.