On Wed, 29 Oct 2008 14:49:05 -0700 (PDT),
emanning@kumc.edu wrote:
Quote:
>I'm having problems using "<>" as criteria for a varchar column in a
>view. The data in this column is '2008-2009' which is supposed to
>mean year 2008 thru 2009. If I set the criteria to "= '2008-2009'"
>then the view returns just those rows with that field equal to
>"2008-2009", like I would expect it to. But if I change the criteria
>to "<'2008-2009'", the view returns nothing. And there are rows to
>return. I tried CAST and CONVERT, thinking the view was interpreting
>the criteria as numbers, but that didn't help. I tried both
>CAST('2008-2009' AS varchar(9)) and CONVERT(varchar(9), '2008-2009').
>Both would work with "=" but not with "<>".
>
>I tried using "<>" on another column in the table and it worked fine.
>This was a "last name" column so there weren't any numbers.
>
>Any help or advice appreciated.
Hi emanning,
Please post table structure (as a CREATE TABLE statement), some sample
data (as INSERT statements), the definition of your view (as a CREATE
VIEW statement), the query you are using to test, the data you got
returned and the data you expected to get.
Based on your description I can only conclude that either you overlooked
some seemingly minor detail that affects your results, or you ran into a
bug - and I consider the former to be more probable than the latter.
--
Hugo Kornelis, SQL Server MVP
My SQL Server blog:
http://sqlblog.com/blogs/hugo_kornelis