tags:

views:

44

answers:

4
A: 

Sounds strange.
Try

select case when "Moody's Corp, Lowe's Companies, Inc., L'Oreal SA" like '%;%' then 1 end

Please refer new edit
TheITGuy
+3  A: 

Are you getting confused between your fields?

You are searching where the comments equal LIKE %;%, and then you appear to be returning the result of the company name? Perhaps it is a comment, but it looks like it isn't. Perhaps your query should be:

select companyName from fields where companyName like '%;%'

or

select coment from fields where Comment like '%;%'

Also never use asterix, select the fields you want to return. This question is a good example of why you should do that! Make it easier to debug in these circumstances.

Tom Gullen
+1 for taking care of details before going to fix the problem, Good I admire it very much.
Muhammad Kashif Nadeem
The data I gave though look like a company name but they are used in different prospactive so the query and its results are fine. Astrix was used as shotcut here but real application uses correct field names. Comments is a text data type so user can enter any text as they like.
TheITGuy
A: 

First things first, get rid of the text datatype. This has been deprecated and you need to replace all instances of this as soon as you can. Use nvarchar(max) or varchar(max) instead.

I get the correct results with your select statement and with Chryss's statement where she/he escapes the semicolon.

You say in one of the comments that this is a simplified version of your real query, perhaps you simplified the problem away?

HLGEM
Ok, I got rid of text data type and converted to varchar(max) and i am still getting same result.
TheITGuy
Please post the real query.
HLGEM
A: 

I think its the problem within the interface I am using to query the database. This database is externally hosted so provider has given us the interface to access that data and it seems there is a problem in that interface.

Thanks for everyone's help and suggestions.

TheITGuy