April 16, 2007 at 3:00 pm
This is my statement in my stored procedure:
Select Count (EmployeeStatus) where .... As 'Employed',
Count(EmployeStatus) Where As 'Employeable',
[Employed] /[Employeable]
Employed has a zero records. and the division does not work.
It could also be due to the fact that
(Stored procedure fails becuase of the aliases I asigned to the EmployeStatus)
Any clues?
April 16, 2007 at 3:07 pm
ISNULL([Employed] /NULLIF([Employeable], 0), @ValueToIndicateDividingByZero)
_____________
Code for TallyGenerator
April 16, 2007 at 10:02 pm
When can I use IIf (IsEmpty(Employed)) in sql server?
April 16, 2007 at 10:16 pm
Hi
For your purpose, ISNULL & NULLIF is enough. If you want to use function like IIF(x,y,z) in SQL, you can use (CASE WHEN ..... THEN ..... END). See BOL for this.
Amit
April 16, 2007 at 11:27 pm
Faye, there is no "IIf" in T-SQL. It's just another language with other commands and operators.
Replacement for IIf you may find in the 1st reply of this topic.
_____________
Code for TallyGenerator
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply