我需要标量转换成内联函数如何将标量转化为内联函数的SQL Server 2008
我的标量函数
create function [dbo].[fun_functional_score] (@phy_id varchar(20))
returns varchar(50)
as
begin
declare @level_initial int, @level_current int
-- initial functional score
set @level_initial=(SELECT pflag.fun_level
FROM tbl_phy_demographic_details as [phy]
inner join tbl_all_purple_flag_level as [pflag] on phy.Demographic_id=pflag.Id
WHERE phy.Physicion_id= @phy_id
and pflag.visited_count in (select MAX(visited_count)-1 from tbl_all_purple_flag_level group by id))
-- current functional score
set @level_current=(SELECT pflag.fun_level
FROM tbl_phy_demographic_details as [phy]
inner join tbl_all_purple_flag_level as [pflag] on phy.Demographic_id=pflag.Id
WHERE [email protected]_id
and pflag.visited_count in (select MAX(visited_count) from tbl_all_purple_flag_level group by id))
-- current functional scor
--set @level_current=(SELECT pflag.fun_level
-- FROM tbl_phy_demographic_details as [phy]
--to calculate functional score
declare @fun_level varchar(20),@result varchar(50)
set @[email protected][email protected]_initial;
if @fun_level = 0 set @result='Maintained'
if @fun_level = '-1' set @result='Minor Improvement'
if @fun_level = '-2' set @result='Moderate Improvement'
if @fun_level = '-3' set @result='Significant Improvement'
if @fun_level = '-4' set @result='Substantial Improvement'
if @fun_level = '1' set @result='Minor Reduction'
if @fun_level = '2' set @result='Moderate Reduction'
if @fun_level = '3' set @result='Significant Reduction'
if @fun_level = '4' set @result='Substantial Reduction'
return @result
end
这是可能的吗?
请不要用[tag:mysql]标记SQL Server问题。 “MySQL”并不意味着“我当前的SQL Server问题”... –
你是否试图问你同一个问题,你有早些发布http://stackoverflow.com/questions/21046294/how-to-return-multilpe- values-from-function-sql-server? – Sachin
是的,有一些错误,这是更新的代码。现在我需要转换成内联函数? – Happy