Like Condition between Columns

Issue

In some cases you need to use like search between the columns in the joining conditions.

This will slow down the query execurion.

Example:

where col1 like ‘%’+col2+’%’

Solution

Use charindex instead of like

where charindex(col2,col1)

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s