Cross / Outer Apply

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • psrathore
    New Member
    • Mar 2008
    • 1

    Cross / Outer Apply

    I am passing a bunch of parameters to my stored proc. The following query uses a few of those parameters alongwith a column value from the outer table using cross apply. I get a compilation error "Incorrect Syntax near B1". this is in the From Clause. Please note that it is the last parameter in the function call

    Code:
    SELECT 
    			 ContractId = @ContractId, BusinessUnitId = B1.BusinessUnitId, B1.ServiceId, B1.CampaignId, 
    			  TotalCount = F1.TotalCount,			
    			  EligibleCount = F1.EligibleCount,
    			  UnitPrice = F1.UnitRate,
    			  TotalPrice = Convert(decimal(20,10),0.00),
    			  BusinessUnitExpenseId = NULL,
    			  IsFixed = CONVERT(bit,'False'),
    			  FixedAmtDealType = CONVERT(varchar(3),''),
    			 ShowFixedAmtDealType  = @ShowFixedAmountWithDealType
    INTO 
    			  #TempAccountDetails 
    FROM			
    			  BusinessUnitAccountingSummaryData AS B1 
    			  CROSS APPLY dbo.func_GetServiceContractFigures(@StartDate, @EndDate, @Service, @BUId, B1.CampaignId) AS F1			
    WHERE
    			  B1.ServiceId = @Service
    			  AND B1.BusinessUnitId = @BUId
    			  AND B1.Date BETWEEN @ContractStartDate AND @ContractEndDate			
    GROUP BY B1.ServiceId, B1.CampaignId, B1.BusinessUnitId
Working...