Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Is there a 'not equal too' symbol in TSQL case's

Status
Not open for further replies.

PreacherUK

Technical User
Sep 26, 2002
156
NL
I'd like to do something like


Select CASE (field1)
WHEN <> 9 THEN FIELD1
ELSE ' '
END AS IDTYPE1

TSQL does not like this syntax :) Am I missing something obvious that my tired eyes are not seeing?
 
Why not just reverse it. I don't think you can do it the other way.

Select CASE (field1)
WHEN = 9 THEN ''
ELSE FIELD1
END AS IDTYPE1

tIM
 
Code:
Select CASE
      WHEN  (field1) != 9 THEN FIELD1
      ELSE ' '
END AS IDTYPE1

[bandito] [blue]DBomrrsm[/blue] [bandito]
 
Code:
Select CASE 
      WHEN (field1)<> 9 THEN FIELD1
      ELSE ' '
END AS IDTYPE1

Questions about posting. See faq183-874
 
If field1 is number, this isn't a good example. Two data types - one column.
If field1 is string, this will work because of implicit conversion (9 into '9').

Anyway, how about no if's:
Code:
SELECT ISNULL(NULLIF(field1, 9, ' '))
 
Dang... typos.
Code:
select isnull(nullif(field1, 9), ' ')
 
Von, my code was just a simplified representation of my thinking, not the actual code :) Thanks all for the input everyone, I think my syntax was just a little squiffy, blame it on my time with VBA ;)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top