Saleh
Saleh

Reputation: 2719

What is the sql statement for searching in text using MS SQL Server 2008?

If I have text sotred in my DB, for example:

"There are 2 books on the table".

Maybe the user wants to search for "books" or the user wants to search in this text for any thing.

What is the best SQL Statement to do that?.

Thanks in advance.

Upvotes: 0

Views: 82

Answers (3)

SQLMenace
SQLMenace

Reputation: 134923

like this

WHERE ColumnName LIKE '%books%'

or look into full text search if you need to do more complicated stuff

Upvotes: 1

Kevin Won
Kevin Won

Reputation: 7186

I think you are looking for a 'like' clause if I understand your question. so

select * from table where column like '%book%'

Upvotes: 2

Martin Smith
Martin Smith

Reputation: 452957

SELECT ... WHERE COL LIKE '%books%'

For more complicated scenarios you might want to investigate Full Text Search

Upvotes: 4

Related Questions