[英]SQL Error: Maximum stored procedure, function, trigger, or view nesting level exceeded
I want to display the data based on the date I selected, [fnDateTxtToWeekNum] will return the weeknum of the date I selected, weeknum is a parameter of [fnBenchmarkData], all available weeknum info stored in the dbo.Weeks table. 我想显示基于所选日期的数据,[fnDateTxtToWeekNum]将返回所选日期的星期数,weeknum是[fnBenchmarkData]的参数,所有可用的Weeknum信息存储在dbo.Weeks表中。
I am getting this error: 我收到此错误:
"Maximum stored procedure, function, trigger, or view nesting level exceeded (limit 32)." “超出了最大存储过程,函数,触发器或视图嵌套级别(限制32)。”
SELECT p.weeknum, p.date, q.ID, q.score
FROM dbo.Weeks AS p
cross apply
[dbo].fnBenchmarkData(p.weeknum) as q
where weeknum = [dbo].[fnDateTxtToWeekNum]('2015-07-02')
Was it because I referenced weeknum twice and have the function calling it self? 是因为我两次引用了Weeknum并让函数调用了self吗? The @weeknum on fnBenchmarkData is referencing dbo.weeks (basically if without where clause, this SQL will return all data for all weeks). fnBenchmarkData上的@weeknum引用dbo.weeks(基本上,如果没有where子句,则此SQL将返回所有星期的所有数据)。 Then I use fnDateTxtToWeeknum, it will return a weeknumber, basically I create a filter so the SQL will only display the data of that specific week I need (convert date I entered to a weeknum). 然后,我使用fnDateTxtToWeeknum,它将返回一个weeknumber,基本上,我创建了一个过滤器,因此SQL将仅显示我需要的特定星期的数据(将输入的日期转换为weeknum)。
/* I need the final output has both weeknum, date, ID, and score. / *我需要最终输出同时包含Weeknum,日期,ID和得分。 The fnBenchmarkData will NOT return weeknum and date infomation by itself, that's why I need to use cross apply. fnBenchmarkData不会单独返回weeknum和date信息,这就是为什么我需要使用交叉应用。 */ * /
I would say the issue might reside inside the function. 我会说问题可能存在于函数中。 Are you using recursion inside the function? 您在函数内部使用递归吗? If you are you might consider using a while-loop to get rid of it. 如果您是,则可以考虑使用while循环来摆脱它。 Looks like you have a recursive issue here. 看来您这里有一个递归问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.