Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Best Way To Speed Up This Query
Message
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Syntaxe SQL
Divers
Thread ID:
01371572
Message ID:
01371609
Vues:
18
Additional thing you can try

SET @sSearchVal = 'sun%'

select myFields from myTable where myFirstField like @sSearchVal or myFirstField LIKE '%' + sSearchVal
union ....

>I have a table called AlertData with 500,000 records in it. This query is taking 11 seconds, which is too long for the client.
>
>
>DECLARE @sSearchVal NVARCHAR(50)
>SET @sSearchVal = '%sun%'
>
>SELECT RowId, ContractNo, SystemId, ItemNumber, Description, Price
>	FROM AlertData
>	WHERE ContractNo LIKE @sSearchVal OR
>		   ItemNumber LIKE  @sSearchVal OR
>		   Description LIKE  @sSearchVal
>
>
>
>There are indexes on all 3 fields.
>
>Thanks
>
>Kevin
If it's not broken, fix it until it is.


My Blog
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform