Showing posts with label iif. Show all posts
Showing posts with label iif. Show all posts

Wednesday, March 28, 2012

query

hi,

i want to achive the IIF functionality.

example

select

iff(employee.empid is not null,'sdfsdf',iif(employee.deptid is not null,'dssdf','sdfsd')) as 'sdsd'

from employee

how to solve this.

thank you

Hi,

did not understand what you wants to achieve! You may use if and try...catch block or you may use case statements too.

Refer CASE and try...catch for more in BOL.

Regards

Heamntgiri S. Goswami

|||

IFF is not a part of TSQL syntax as far as i know...though this function is provided in sql server 2005 reporting services (thats the place i used it)...

finctionality of IFF is

IFF(mycondition , ValueWhenMyConditionTrue, ValueWhenMyConditionFalse)

IFF can also be nested...so for ValueWhenMyConditionFalse u can write another IFF...as is done in ur case...i hope u'll be able to 'decode' ur actual code now...

|||You can use an IF in SQL.

Its normally shown as

IF EXISTS (SELECT * FROM Orders WHERE OrderNo = @.OrderNo) THEN|||Also you use NotIsNull(Expr1, Expr2)
|||

IIF is not available in T-SQL.

But you can use Case When,

Case When employee.empid is NOT NULL Then 'sdfsdf' Else (Case When employee.deptid is not null Then 'dssdf' Else 'sdfsd' End) End

Saturday, February 25, 2012

Q:conditional formating

Hello,
I am trying to color negative detail lines with the following.
=iif((Fields!Amt1.Value-Fields!Amt2.Value)<0,"Red","Black")}
It is working if the value is not zero. Some 0.00 values are black but some
of them are red. What is problem?
Jim.Hi Jim
I think the problem is because you haven't specified the text color for
the result value zero.
You can try specifying the condition as "<=0" if you want the zero
values in red like
=iif((Fields!Amt1.Value-Fields!Amt2.Value)<=0,"Red","Black")
Else if you want zero values in black you can try
=iif((Fields!Amt1.Value-Fields!Amt2.Value)>=0,"Black","Red")
Hope this solves your problem
Regards
Prathima.C
JIM.H. wrote:
> Hello,
> I am trying to color negative detail lines with the following.
> =iif((Fields!Amt1.Value-Fields!Amt2.Value)<0,"Red","Black")}
> It is working if the value is not zero. Some 0.00 values are black
but some
> of them are red. What is problem?
> Jim.|||I did that but it did not change anything. Some of zeros are blank, some are
red. Is there any precession issue?
"prathima.chandramouli@.gmail.com" wrote:
> Hi Jim
> I think the problem is because you haven't specified the text color for
> the result value zero.
> You can try specifying the condition as "<=0" if you want the zero
> values in red like
> =iif((Fields!Amt1.Value-Fields!Amt2.Value)<=0,"Red","Black")
> Else if you want zero values in black you can try
> =iif((Fields!Amt1.Value-Fields!Amt2.Value)>=0,"Black","Red")
> Hope this solves your problem
> Regards
> Prathima.C
>
>
>
> JIM.H. wrote:
> > Hello,
> > I am trying to color negative detail lines with the following.
> > =iif((Fields!Amt1.Value-Fields!Amt2.Value)<0,"Red","Black")}
> > It is working if the value is not zero. Some 0.00 values are black
> but some
> > of them are red. What is problem?
> > Jim.
>