-1

I have a View that I like to search a word in it.
How can I search a word in all column of table?

SELECT *
  FROM [Vw_FullTechInformation]
user3713495
  • 29
  • 1
  • 6

2 Answers2

1

You can do full-text search on all columns like this

-- using contains
SELECT *
  FROM [Vw_FullTechInformation]
  WHERE CONTAINS(*, 'YourSearchText');
--using freetext

SELECT *
  FROM [Vw_FullTechInformation]
  WHERE FREETEXT(*, 'YourSearchText');
--using freetexttable
  SELECT *
  FROM FREETEXTTABLE([Vw_FullTechInformation],*,'YourSearchText')

But your table/view should be full-text indexed for this to work.

DiDi
  • 110
  • 6
  • This might help you on implementing full-text search on view [Implementing Full-Text Search on View](http://www.dotnetfunda.com/articles/show/1019/implementing-full-text-search-on-view) And [Enable Full-Text Search on View with Inner Join](http://stackoverflow.com/questions/8486703/enable-full-text-search-on-view-with-inner-join) – DiDi Jun 21 '14 at 20:00
  • My View has `OUTER JOIN` so I couldn't create cluster Index for Full-Text search. – user3713495 Jun 27 '14 at 03:24
  • Then may be this is your question, [Using Full-Text Search in SQL Server 2008 across multiple tables, columns](http://stackoverflow.com/questions/403630/using-full-text-search-in-sql-server-2008-across-multiple-tables-columns) and the solution [Indexed Views With Outer Joins](http://www.sqlservercentral.com/articles/Indexing/indexedviewswithouterjoins/1884/) – DiDi Jun 27 '14 at 19:41
0

Try,

firsttable Record Like this

ID  Value
1   First
2   Second
3   Third
4   FOUR
5   FIVE
6   six

SELECT *  FROM firsttable 
WHERE Value LIKE '%s'           
   OR Value LIKE 's%'        
   OR Value LIKE '%s'        
   OR Value LIKE '%s%' ; 

**Output Like**

ID  Value
1   First
2   Second
6   six
Vinoth_S
  • 1,380
  • 1
  • 12
  • 15