The thing is that you are trying to create inline table valued function where only allowed statement is RETURN. for e.g.CREATE FUNCTION f_GetOffer (@startDate datetime)RETURNS tableasReturn(SELECT * from Offers where StartDate=@startDate)
If you want to create multi-statement function, you need to define table structure as well in the RETURN clause:CREATE FUNCTION f_GetOffer (@startDate datetime)RETURNS @temp table(col1 int,col2 varchar(20), ...)Asbegindeclare @seasonDate datetimeset @seasonDate=(select CalcSeasonDate from Seasons where sid=19)declare @temp1 table(col1 int,col2 varchar(20), ...)insert into @temp1SELECT * from Offers where StartDate=@startDateRETURNend
Harsh AthalyeIndia."The IMPOSSIBLE is often UNTRIED"