> In the simplified code below, I am getting an error around the IF statement.
> Could someone let me know what's wrong here?
Many thanks Phil,
I think that got me past one of the problems.
Now, when I run the statement below in the Query Analyser, I receive the
error "Incorrect syntax near '>'"
Select descr,
Case 1 > 2
Then unitprc
else 0
end as cost
from dbo.invcustl
Do you know what would be causing that error?
Many thanks
Mike Thomas
>> I am migrating date from Access 2000 to SQL Server and am trying to deal
>> with replacing the IIF with an IF.
[quoted text clipped - 17 lines]
> Cheers
> Phil
RoyVidar - 11 Nov 2005 18:09 GMT
Mike Thomas wrote in message <e9zZSGu5FHA.2036@TK2MSFTNGP14.phx.gbl> :
> Many thanks Phil,
>
[quoted text clipped - 14 lines]
> Many thanks
> Mike Thomas
I don't think 1 will ever be greater than 2;-)
select descr,
case when quantity > 1
then
unitprc
else
0
end as cost
From dbo.invcustl

Signature
Roy-Vidar
Mike Thomas - 11 Nov 2005 18:23 GMT
Thanks Roy-Vidar,
You are right, 1 will never be greater than 2. However, the problem I am
trying to solve here is why I am getting an error around the '>' sign. I do
not see why the code as I have written it should not at least run, and at
least always return zero.
Select descr,
Case 1 > 2
Then unitprc
else 0
end as cost
from dbo.invcustl
Tnaks
Mike Thomas
> Mike Thomas wrote in message <e9zZSGu5FHA.2036@TK2MSFTNGP14.phx.gbl> :
>> Many thanks Phil,
[quoted text clipped - 26 lines]
> end as cost
> From dbo.invcustl
RoyVidar - 11 Nov 2005 18:38 GMT
Mike Thomas wrote in message <OuZlI0u5FHA.1464@tk2msftngp13.phx.gbl> :
> Thanks Roy-Vidar,
>
[quoted text clipped - 45 lines]
>>
>> -- Roy-Vidar
Was that with or without the little keyword "when" in the Case When
statement?

Signature
Roy-Vidar
Mike Thomas - 11 Nov 2005 20:05 GMT
Many thanks Roy-Vidar you were exactly right.
Mike Thomas
> Mike Thomas wrote in message <OuZlI0u5FHA.1464@tk2msftngp13.phx.gbl> :
>> Thanks Roy-Vidar,
[quoted text clipped - 49 lines]
> Was that with or without the little keyword "when" in the Case When
> statement?
Philipp Stiefel - 12 Nov 2005 09:49 GMT
> I think that got me past one of the problems.
>
[quoted text clipped - 9 lines]
>
> Do you know what would be causing that error?
Sorry, I'm afraid I made a little mistake there. I should be:
Select descr,
Case WHEN 1 > 2
Then unitprc
else 0
end as cost
from dbo.invcustl
I just missed the WHEN.
Cheers
Phil