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
 IF function

Author  Topic 

santana
Yak Posting Veteran

72 Posts

Posted - 2009-10-27 : 09:49:02
Hi,

I would like to know, If there is in the SQL Server, one function that works as IF function?

For example:

select
If (tableA.field1 <> tableB.filed1), then 0
else is (tableB.field1 <> tableC.field1) then 1 else 2.
from tableA, tableB, tableC

Could you help me, please??

Thank you!

Regards,

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2009-10-27 : 09:55:18

select
case when (tableA.field1 <> tableB.filed1) then 0
when (tableB.field1 <> tableC.field1) then 1 else 2 end
from tableA, tableB, tableC


Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

senthil_nagore
Master Smack Fu Yak Hacker

1007 Posts

Posted - 2009-10-27 : 09:55:24
Use Case

select
case when (tableA.field1 <> tableB.filed1) then 0
when (tableB.field1 <> tableC.field1) then 1 else 2 end as column_name
from tableA, tableB, tableC

Senthil.C
------------------------------------------------------
[Microsoft][ODBC SQL Server Driver]Operation canceled

http://senthilnagore.blogspot.com/
Go to Top of Page
   

- Advertisement -