Search code examples
sql-server-2005sql-likecontains

SQL LIKE convert to SQL CONTAINS


What is the right syntax for converting a SQL Like to Contains in the following fragment statement:

WHERE ReferenceNo LIKE '%' + @SearchString+ '%'

I have converted it to:

WHERE ReferenceNo CONTAINS(VendorName, @SearchString)

VendorName is in the SELECT statement.

Thanks in advance. :)


Solution

  • If you were just converting the WHERE statement you showed, it would be

    WHERE CONTAINS(ReferenceNo, @SearchString)