Create PROCEDURE [dbo].[Sp_TaccountdetailsB]
@i int,
@UserId int,
@amount decimal(18,2),
@duserid int,
@caccountnumber varchar(50)
AS
BEGIN
if @i=0
BEGIN
select AccountNumber,AccountType,Amount from tblT_AccountDetailsB where AccountDetailsId=( select MAX(AccountDetailsId) from tblT_AccountDetailsB where UserId = @UserId)
END
ELSE IF @i=1
BEGIN
select AccountNumber,Amount,Credited,Debited from tblT_AccountDetailsB where AccountDetailsId=(select MAX(AccountDetailsId) from tblT_AccountDetailsB where UserId=@UserId)
END
ELSE IF @i=2
BEGIN
select AccountNumber,Amount,Credited,Debited from tblT_AccountDetailsB where UserId=@UserId
END
ELSE IF @i=3
BEGIN
Declare @cAccountType varchar(50)
Declare @dAccountType varchar(50)
Declare @cBranchId int
Declare @dBranchId int
Declare @cuserid int
Declare @daccountnumber varchar(50)
declare @damount decimal(18,2)
declare @camount decimal(18,2)
set @daccountnumber=(select AccountNumber from tblT_AccountDetailsB where UserId=@duserid)
set @cuserid=(select distinct UserId from tblT_AccountDetailsB where AccountNumber=@caccountnumber)
set @cAccountType=(select Distinct AccountType from tblT_AccountDetailsB where UserId=@cuserid)
set @dAccountType=(select Distinct AccountType from tblT_AccountDetailsB where UserId=@duserid)
set @cBranchId=(select Distinct BranchId from tblT_AccountDetailsB where UserId=@cuserid)
set @dBranchId=(select Distinct BranchId from tblT_AccountDetailsB where UserId=@UserId)
set @damount=((select Amount from tblT_AccountDetailsB where UserId=@duserid)-@amount)
set @camount=((select Amount from tblT_AccountDetailsB where UserId=@cuserid)+@amount)
insert into tblT_AccountDetailsB (AccountNumber,BranchId,AccountType,Amount,UserId,Debited) values (@daccountnumber,@dBranchId,@dAccountType,@damount,@duserid,@amount)
insert into tblT_AccountDetailsB (AccountNumber,BranchId,AccountType,Amount,UserId,Credited) values (@caccountnumber,@cBranchId,@cAccountType,@camount,@cuserid,@amount)
end
this stored procedure is executed but not returns the UserId
please help me how to write Stored Procedure If i want to retun UserId Please...