mercredi 20 janvier 2016

Most effective way to check sub-string exists in Comma separated string in SQL Server

I have a comma separated list field available which has values like 'Product1,Product2,Product3'. I need to search whether the given product name exists in this field.

I used below SQL and is working fine.

Select * from ProductsList where productname like '%Product1%'.

The above query is working very slow. Will there be a most effective way I can search for a Product Name in the comma separated list to improve the performance of the query. Please note I have to search comma separated list before performing any other select statements.

Aucun commentaire:

Enregistrer un commentaire