1

Hi am using a scalar function to compute some values and add it as a column while retriving the table.The query i was using is

Select * ,dbo.funcnme(@userid,itemid) as newvalue  from items

now i have a scenario in which i have to call a function based on a items value but i cant get it right.the query i tried is

select *,
    Case when items.Value=4 
        then dbo.funcnme(@userid,itemid) as newvalue 
        else dbo.newfuncnme(@userid,itemid)  
    as newvalue  from items

it shows

Incorrect syntax near the keyword 'as'.

Whats wrong here.How can i do it please help.

4

1 に答える 1

3

の がありませんENDCASE、エイリアスも最後にある必要があります。

select *,
    Case when items.Value=4 
        then dbo.funcnme(@userid,itemid) 
        else dbo.newfuncnme(@userid,itemid)  
    END as newvalue  
from items
于 2012-06-08T07:29:43.603 に答える