Hi I'm still new in TSQL. How can I output Scalar variables so that my vb code can access it?
in VB I use the rs method. In this case I will have to create 3 rs to be be able to access the data below. I would like to have a stored proc that can give me the 4 values I need without using multiple rs.
Create PROCEDURE [dbo].[sp_tblTransaction_GET_All_Totals]
@TransID bigint
AS
Declare @MyTotalCharges as money
Declare @MyTotalDiscounts as money
Declare @MyTotalPayments as money
Declare @TotalCharges as money
Declare @TotalDiscounts as money
Declare @TotalPayments as money
Declare @Balance as money
SELECT @MyTotalCharges = SUM(Amount)
FROM tblTransactionDetails
WHERE (TransID = @TransID)
SELECT @MyTotalDiscounts = SUM(Amount)
FROM tblTransaction_DP
WHERE (TransID = @TransID)
SELECT @MyTotalPayments = SUM(Amount)
FROM tblPayments
WHERE (TransID = @TransID)
--Below are the scalar values I need to be ouputed and accessed by my vb app.
--How can I output the values below?
@TotalCharges = @MyTotalCharges
@TotalDiscounts = @MyTotalDiscounts
@TotalPayments = @MyTotalPayments
@Balance = (@MyTotalCharges - @MyTotalDiscounts - @MyTotalPayments)