Asked By Mass K
06-Apr-09 12:56 PM

Hi, I am not sure why this query is not working. Does anyone have an idea? Thx
(select case when dbo.fgetstcode( sy.stid ) = 'CNV' then isnull(isnull(max(rate.rate),0) * 0.01 * 0.1 * isnull(max(sy.facevalue),0) / (isnull((select mv.price from linkedvpm.vpm.dbo.mv mv where convert(varchar,date,101) = @InqDate and mv.syid = openev.syid),1)),'No Yield')
else
case when dbo.fgetstcode( sy.stid )= 'CVP' then isnull((if(select convert(decimal(15,12), (udf.value)) from linkedvpm.vpm.dbo.USERDEFINEDCOLUMNVALUE UDF where UDF.rowid = openev.syid and UDCOLID = '10000018') IS NULL begin select max(rate.rate) end else (select convert(decimal(15,12), (udf.value)) from linkedvpm.vpm.dbo.USERDEFINEDCOLUMNVALUE UDF where UDF.rowid = openev.syid and UDCOLID = '10000018') end end ) * 0.5 / (isnull((select mv.price from linkedvpm.vpm.dbo.mv mv where convert(varchar,date,101) = @InqDate and mv.syid = openev.syid),1)),'No Yield')
else
case when dbo.fgetstcode( sy.stid )= 'STO' then isnull(isnull(max(rate.rate),0) * 0.1 * 0.01 * isnull(max(sy.facevalue),0) / (isnull((select mv.price from linkedvpm.vpm.dbo.mv mv where convert(varchar,date,101) = @InqDate and mv.syid = openev.syid),1)),'No Yield')
else
case when dbo.fgetstcode( sy.stid )= 'CVF' then isnull(isnull(max(rate.rate),0) * 0.1 * 0.01 * isnull(max(sy.facevalue),0) / (isnull((select mv.price from linkedvpm.vpm.dbo.mv mv where convert(varchar,date,101) = @InqDate and mv.syid = openev.syid),1)),'No Yield')
end
end end end ) as CurrentYield,
I get the following error:
Msg 156, Level 15, State 1, Procedure sp910, Line 190
Incorrect syntax near the keyword 'if'.
Msg 156, Level 15, State 1, Procedure sp910, Line 190
Incorrect syntax near the keyword 'end'.
Msg 170, Level 15, State 1, Procedure sp910, Line 190
Line 190: Incorrect syntax near ','.
Msg 170, Level 15, State 1, Procedure sp910, Line 192
Line 192: Incorrect syntax near ','.
Msg 170, Level 15, State 1, Procedure sp910, Line 194
Line 194: Incorrect syntax near ','.
Msg 156, Level 15, State 1, Procedure sp910, Line 209
Incorrect syntax near the keyword 'as'.