Hi Guys,
I'm working in a Table Valued Function that's referred to in a stored procedure.
In the Table Valued funciton, I want to tell it to get the top number of records based on the number of months declared in teh variable. My understanding is that this should be really simple, however, when I put the "Select Top (@NumOfMonths) etc" in the function, it starts complaining about the other sections of the function.
The current script is below (names changed to keep company stored procedures secure)
SQL
ALTERFUNCTION[dbo].[Table](@profileIdint,@currentDatedatetime,@testIduniqueidentifier,@numOfMonthsint,@filtertinyint)RETURNSTABLEASRETURN(selecttop(@numOfMonths)*fromdbo.Table(@profileId,@currentDate,@testId,@numOfMonths,@filter)orderbyDatedescstat.DataIdasDatad,dbo.GetStatus(Score,MatchingSource,Limit,@...