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
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Am I smart or am I Bart?

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2001-12-16 : 11:59:03
Tomaz writes "Hi guys,

I'm new to T-SQL and I didn't find the IIF command in standard command set. So I implemented it like this:

IIF(value=10, 100, 200)

can be emulated with

ISNULL(NULLIF(ISNULL(NULLIF(@value,10),100),@value),200)

Sincerely,
Tomaz"

Arnold Fribble
Yak-finder General

1961 Posts

Posted - 2001-12-16 : 12:09:28
Ingenious! But you may find CASE easier on the eye and brain:

CASE WHEN @value=10 THEN 100 ELSE 200 END


Go to Top of Page

Merkin
Funky Drop Bear Fearing SQL Dude!

4970 Posts

Posted - 2001-12-16 : 19:06:45
Ay Carrumba!

DOH



Damian
Go to Top of Page
   

- Advertisement -