CONTAINS and wildcard

Is it a good idea to have multiple contains? I have this query:

Select * from myTable where contains (Col1, 'Africa') or (Col2, 'Africa')

Also, I tried this, didn't return anything:

Select * from myTable where contains (Col1, 'Africa*') or (Col2, 'Africa')

Both Col1 and Col2 has the string 'Africa' and 'African' in it.


--sharif
Sharif Islam [ Mo, 29 Oktober 2007 21:59 ] [ ID #1856894 ]

Re: CONTAINS and wildcard

On Oct 29, 8:59 pm, Sharif Islam <mis... [at] npspam.uiuc.edu> wrote:
> Is it a good idea to have multiple contains? I have this query:
>
> Select * from myTable where contains (Col1, 'Africa') or (Col2, 'Africa')
>
> Also, I tried this, didn't return anything:
>
> Select * from myTable where contains (Col1, 'Africa*') or (Col2, 'Africa')
>
> Both Col1 and Col2 has the string 'Africa' and 'African' in it.
>
> --sharif

Hi Sharif,

What version of SQL Server are you using? What is the error message
you are getting? Is the table configured for Full-Text Indexing?

Also - your syntax for the CONTAINS statement is incorrect. Try:
SELECT *
FROM myTable
WHERE CONTAINS(Col1, '"Africa*"')
OR CONTAINS(Col2, '"Africa*"')

Good luck!
J
jhofmeyr [ Di, 30 Oktober 2007 00:51 ] [ ID #1857730 ]

Re: CONTAINS and wildcard

jhofmeyr [at] googlemail.com wrote:
> On Oct 29, 8:59 pm, Sharif Islam <mis... [at] npspam.uiuc.edu> wrote:
>> Is it a good idea to have multiple contains? I have this query:
>>
>> Select * from myTable where contains (Col1, 'Africa') or (Col2, 'Africa')
>>
>> Also, I tried this, didn't return anything:
>>
>> Select * from myTable where contains (Col1, 'Africa*') or (Col2, 'Africa')
>>
>> Both Col1 and Col2 has the string 'Africa' and 'African' in it.
>>
>> --sharif
>
> Hi Sharif,
>
> What version of SQL Server are you using? What is the error message
> you are getting? Is the table configured for Full-Text Indexing?
>
> Also - your syntax for the CONTAINS statement is incorrect. Try:
> SELECT *
> FROM myTable
> WHERE CONTAINS(Col1, '"Africa*"')
> OR CONTAINS(Col2, '"Africa*"')

ah, that was it, thanks!

--sharif
Sharif Islam [ Di, 30 Oktober 2007 15:07 ] [ ID #1857740 ]
Datenbanken » comp.databases.ms-sqlserver » CONTAINS and wildcard

Vorheriges Thema: SqlClient connection to SQL 2005 creates 5000 tcp connections!
Nächstes Thema: Error message with stored procedure