0
declare @company_branch_id uniqueidentifier = 'd3534ff2-b2b2-473f-9be1-e03069bf5c87'
declare @dateFrom date = '10/8/2013'
declare @dateTo date = '11/9/2013'
DECLARE @tbl TABLE(
tbl_Ref varchar(50)
, Reference varchar(100)
, customer_branch_id uniqueidentifier
, trans_date datetime
, duedate datetime
, Charge decimal(18,4)
, Credits decimal(18,4)
, Allocated decimal(18,4)
, Outstanding decimal(18,4)
, pay_amount decimal(18,4))
Insert into @tbl
Exec [dbo].[usp_getCustomerBalanceRpt] @company_branch_id, @dateFrom, @dateTo
UPDATE @tbl
SET trans_date = (SELECT tbl_Rental_InvoiceMaster.Date
FROM tbl_Rental_InvoiceMaster
INNER JOIN @tbl ON @tbl.Reference = tbl_Rental_InvoiceMaster.Reference
WHERE tbl_Rental_InvoiceMaster.Reference= @tbl.Reference
AND @tbl.tbl_Ref='Rental Invoice')
SELECT * FROM @tbl
@company_branch_id,@dateFrom,@dateTo是傳遞給sp的參數。 當執行被顯示在上面的代碼ERROR鄰近根據另一個存儲過程的值更新臨時表的值
INNER JOIN @tbl ON @tbl.Reference = tbl_Rental_InvoiceMaster.Reference
WHERE tbl_Rental_InvoiceMaster.Reference= @tbl.Reference
AND @tbl.tbl_Ref='Rental Invoice'
爲'Must declare the scalar variable "@tbl".'