CREATE FUNCTION GetRecode
(
-- Add the parameters for the function here
@examid int,
@classid int,)
RETURNS TABLE
ASRETURN
(
declare @sql varchar(4000)
set @sql='select [r_classid] '
select @sql=@sql+', max(case r_subjectid when '''+rtrim([r_subjectid])+''' then [cj] else '''' end)['+ rtrim(r_subjectid)+']'
from (select distinct [r_subjectid] from [Tab_Recode] where r_examid=@examid and [r_classid]=@classid and isnumeric(cj)=1 )as a
set @sql=@sql+' from (SELECT [r_classid],[r_subjectid],avg(cast(cj as int)) cj FROM [xxt_data].[dbo].[Tab_Recode] where r_examid='+@examid+' and [r_classid]='+@classid+' and isnumeric(cj)=1 group by [r_subjectid],[r_classid]) t group by [r_classid]'
exec(@sql)
)
GO
消息 102,级别 15,状态 1,过程 GetRecode,第 12 行
')' 附近有语法错误。
消息 102,级别 15,状态 1,过程 GetRecode,第 24 行
')' 附近有语法错误。
(
-- Add the parameters for the function here
@examid int,
@classid int,)
RETURNS TABLE
ASRETURN
(
declare @sql varchar(4000)
set @sql='select [r_classid] '
select @sql=@sql+', max(case r_subjectid when '''+rtrim([r_subjectid])+''' then [cj] else '''' end)['+ rtrim(r_subjectid)+']'
from (select distinct [r_subjectid] from [Tab_Recode] where r_examid=@examid and [r_classid]=@classid and isnumeric(cj)=1 )as a
set @sql=@sql+' from (SELECT [r_classid],[r_subjectid],avg(cast(cj as int)) cj FROM [xxt_data].[dbo].[Tab_Recode] where r_examid='+@examid+' and [r_classid]='+@classid+' and isnumeric(cj)=1 group by [r_subjectid],[r_classid]) t group by [r_classid]'
exec(@sql)
)
GO
消息 102,级别 15,状态 1,过程 GetRecode,第 12 行
')' 附近有语法错误。
消息 102,级别 15,状态 1,过程 GetRecode,第 24 行
')' 附近有语法错误。
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货