September 27, 2010 at 6:35 pm
Hello,
I want to run a select command, on the basis of LIKE clause.
In WHERE condition, I want to include:
WHERE column1 LIKE '%Column2%'. i.e. I want to include the column_name.
Is it possible ? Please help
Thanks in advance!
September 27, 2010 at 6:49 pm
touchmeknot (9/27/2010)
Hello,I want to run a select command, on the basis of LIKE clause.
In WHERE condition, I want to include:
WHERE column1 LIKE '%Column2%'. i.e. I want to include the column_name.
I'm not sure I understand what you are trying to do. Are you trying to find values in column1 that contain what is in column2? Is column2 a N/VARCHAR field?
If so try this:
WHERE column1 LIKE '%' + Column2 + '%'
If that doesn't do it you will need to provide more information. Here is a link that can help you with how to ask the question to get the best answer: http://www.sqlservercentral.com/articles/Best+Practices/61537/
September 27, 2010 at 6:50 pm
How about:
WHERE Column1 LIKE '%' + Column2 + '%'
Note that starting off with a '%' will mean that you won't effectively be able to use an index.
Wayne
Microsoft Certified Master: SQL Server 2008
Author - SQL Server T-SQL Recipes
September 28, 2010 at 10:54 am
Thanks UMG Developer :). You provided the solution I was looking for.
Thanks WayneS.
September 28, 2010 at 11:41 am
Your welcome, thanks for letting us know that worked for you.
Viewing 5 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply