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.
I am getting this error:
"Maximum stored procedure, function, trigger, or view nesting level exceeded (limit 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? The @weeknum on fnBenchmarkData is referencing dbo.weeks (basically if without where clause, this SQL will return all data for all weeks). 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).
/* I need the final output has both weeknum, date, ID, and score. The fnBenchmarkData will NOT return weeknum and date infomation by itself, that's why I need to use cross apply. */
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. Looks like you have a recursive issue here.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.