Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Using CONTAINS in where clause
Message
 
 
À
28/03/2011 14:14:29
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Syntaxe SQL
Versions des environnements
SQL Server:
SQL Server 2008
Application:
Web
Divers
Thread ID:
01505253
Message ID:
01505270
Vues:
40
The LIKE will find the search value at the beginning of the text only and Contains - any word that matches criteria. It means that Contains is redundant in your case.

>I have a SQL command that is executed in one of the applications I support and there is something I can't reminder. Lets take a look at a simplified version of the SQL command:
>
>
>DECLARE @Parameter12 Varchar(30)
>DECLARE @Parameter1 Varchar(30)
>
>SET @Parameter12='"MERCEDES*"'
>SET @Parameter1='MERCEDES%'
>
>SELECT MyTable.PrimaryKey
> WHERE Contains (MyTable.VehicleMake, @Parameter12) AND MyTable.MyTable.VehicleMake LIKE @Parameter1
>
>
>When I look at the SQL today, I have been wondering what does it give more to have the Contains clause in there. The VehicleMake is full text indexed. However, because the second part of the WHERE clause is taking everything that starts with MERCEDES, I am questioning the use of the Contains syntax. The way I see it, it doesn't change anything as even if MERCEDES is contained in the VehicleMake field, the fact that the second part of the WHERE clause takes everything starting with it, it will not give me any additional records.
>
>Is this your understanding as well?
--sb--
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform