Last active
August 29, 2015 14:02
-
-
Save BalajiIyengar/af98f036347773ebc16d to your computer and use it in GitHub Desktop.
Create Stored Procedures
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Create procedure sp_createInstallment | |
( | |
@studentId int, | |
@installmentNo int, | |
@monthlyPattern int, | |
@preferredDate date, | |
@perferredAmount money | |
) | |
AS | |
Begin | |
Declare | |
@feeAmount money, | |
@remainingAmount money | |
set @feeAmount=(select F.Amount from tblStudentDetails S inner join tblFeesMaster F on S.CourseId=F.CourseId | |
where S.StudentId=@studentId and S.isActive=1 and F.isActive=1) | |
while(@installmentNo!=0) | |
Begin | |
set @remainingAmount=@feeAmount-@perferredAmount | |
insert into tblfeeStructure(StudentID,InstallmentNo,InstallmentAmount,InstallmentDate,AmountRemaining,CreatedDate) values(@studentId,@installmentNo,@perferredAmount,DATEADD(MONTH,1,@preferredDate),@remainingAmount,GETDATE()) | |
set @installmentNo=@installmentNo-1 | |
set @feeAmount=@feeAmount-@perferredAmount | |
set @preferredDate=DATEADD(MONTH,1,@preferredDate) | |
End | |
End |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment