函数中包含的Select语句无法将数据返回给client_New

时间:2018-12-05 15:22:28

标签: sql-server tsql stored-functions

我一直在阅读有关问题标题的错误,但我无法弄清楚下面代码中的错误是什么

{ role: "readWrite", db: "database_00x" }

我得到的错误是

  

函数中包含的Select语句无法将数据返回到   客户

1 个答案:

答案 0 :(得分:0)

您需要将SELECT的结果放入返回表中,然后返回该表。

CREATE function [RPT].[MonthlyRollupDates_Delimited]()
--notice i modified the table to match the select statement, but assumed datatypes
RETURNS @table TABLE (CalendarDate datetime, BusinessDay int, Label char(10))
AS
BEGIN

declare @Count int
SET @Count = month(getdate()) + 12

--place your select into the table variable
insert into @table
Select top (@Count) 
    CalendarDate
    ,BusinessDay
    ,Label
from  
    MonthlyRollupDates
order by 
    Calendardate desc

return
end
GO