Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Having on calculated field
Message
 
 
To
16/07/2011 09:39:13
General information
Forum:
Microsoft SQL Server
Category:
SQL syntax
Environment versions
SQL Server:
SQL Server 2008
Miscellaneous
Thread ID:
01518229
Message ID:
01518380
Views:
41
>Hi Naomi,
>
>see my comment below. I'm not seeing how to fix this from my google searches.
>
>>Here is how you can re-write the ClaimItemStatus function to be inline table-valued
>>
>>create function dbo.ClaimItemStatus
>>( 
>>   @ClaimItemPk int,
>>    @Start Date,
>>    @End Date,
>>    @DayLimit Int
>>) 
>>RETURNS TABLE
>>AS 
>>
>>with cte as (select case when @Start IS NOT NULL and @End IS NOT NULL 
>>          THEN 'Settled'
>>         WHEN @Start IS NOT NULL 
>
>**** I'm getting a syntax error on the case here: Expecting AND, OR, or THEN****
>>                  case when @DayLimit > (select count(*) .... ) -- here we can either use direct query or your scalar function - I prefer direct count
>
>>                      THEN 'OverDue'
>>                  else
>>                       'Pending' 
>>               END
>>        ELSE -- what else is not covered ?
>>           'Unknown'
>>      END as StatusDescr)
>>
>>select StatusDescr, case StatusDescr WHEN 'Settled' then 2 when 'Pending' then 4 when 'OverDue' then 3 when 'Unknown' then 5 end as [Status]
>>from cte
>>
>>GO
>>
The error is very explicit. You're missing THEN keyword before inner case starts.
If it's not broken, fix it until it is.


My Blog
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform