本文介绍了在运行此功能时,我在关键字“开始"附近遇到此错误“语法不正确",该如何解决?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

CREATE FUNCTION example
(
@id int
)
RETURNS @tableout TABLE

begin
 declare @sum float,@lstname nvarchar(50),@fstname nvarchar(50)
 select @sum=sum(marks),@lstname=lastname,@fstname=firstname from student where @id=idstud
 insert into @tableout values (@sum)
end
GO

推荐答案

CREATE FUNCTION example
(
@id int
)
RETURNS @tableout TABLE( col1 int)

begin
 declare @sum float,@lstname nvarchar(50),@fstname nvarchar(50)
 select @sum=sum(marks),@lstname=lastname,@fstname=firstname from student where @id=idstud
 insert into @tableout values (@sum)
  return
 end

GO





您忘记在数据表中包括列.同样在那之后,您必须在结束之前添加return关键字.





You forgot to include column in the datatable. ALso after that you have to include return keyword before end.


这篇关于在运行此功能时,我在关键字“开始"附近遇到此错误“语法不正确",该如何解决?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

11-01 22:16