string – how to use like and substring in where clause in sql

string – how to use like and substring in where clause in sql

You can concatenate strings to form your LIKE string. To trim the first 3 and last 3 characters from a string use the SUBSTRING and LEN functions. The following example assumes your match string is called @input and starts and ends with 3 quote marks that need to be removed to find a match:

select name from Items where name like % + SUBSTRING(@input, 3, LEN(@input) - 4) + %

string – how to use like and substring in where clause in sql

Leave a Reply

Your email address will not be published. Required fields are marked *