Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Problem with Cases

Author  Topic 

SQLWonderer
Starting Member

1 Post

Posted - 2011-11-08 : 02:40:26
Hi can anyone tell me whats wrong with this:

'XYZ'=
Case
When contactnote like '%ABC%' then 'No'
Else 'Yes'
end

cause I am getting both yes and no responsible hence the duplication
many thanks,

S

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-11-08 : 03:05:43
nope you wont get both. I think it may be that you would have records satisfying both in table. If you can show some sample data then we would get more idea

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

jassi.singh
Posting Yak Master

122 Posts

Posted - 2011-11-08 : 03:36:48
SELECT
Case
When 'abc' like '%ABC%' then 'No'
Else 'Yes'
END


Above query give you No.

SELECT
Case
When 'tttt' like '%ABC%' then 'No'
Else 'Yes'
end

Above query give you Yes.

Please mark answer as accepted if it helped you.

Thanks,
Jassi Singh
Go to Top of Page
   

- Advertisement -