I have 12 month value
Jan=2000
Feb=2000
Mar=2000
April=3000
May=2000
June=2000
...
create Procedure [dbo].[Proc_SaveEmployeeDeductionDetails]
@p_EmployeeId INT =0,
@p_CalendarYearId INT =0,
@p_CalendarMonthId INT =0,
@p_HouseRentAmountJan decimal(16,2)=NULL,
@p_HouseRentAmountFeb decimal(16,2)=NULL,
@p_HouseRentAmountMar decimal(16,2)=NULL,
@p_HouseRentAmountApr decimal(16,2)=NULL,
@p_HouseRentAmountMay decimal(16,2)=NULL,
@p_HouseRentAmountJun decimal(16,2)=NULL
as
Begin
If(@p_Action='Save')
Begin
INSERT INTO PYRLL_TDS_Employee_HouseRentDetails
(FK_Employee_Id,FK_Calendar_Month_Id,FK_CalendarYear_Master_Id,Year,
HouseRentAmount,CreatedBy,CreatedOn,CreatedOnUTC,Disabled)
values --@p_CalendarMonthId
(@p_EmployeeId,1,@p_CalendarYearId,
(select Name from PYRLL_SYSTM_CalendarYear_Master
where PK_CalendarYear_Master_Id=@p_CalendarYearId and IsActive=1),
@p_HouseRentAmountJan,@p_CreatedBy,
GETDATE(),GETUTCDATE(),0)
INSERT INTO PYRLL_TDS_Employee_HouseRentDetails
(FK_Employee_Id,FK_Calendar_Month_Id,FK_CalendarYear_Master_Id,Year,
HouseRentAmount,CreatedBy,CreatedOn,CreatedOnUTC,Disabled)
values --@p_CalendarMonthId
(@p_EmployeeId,2,@p_CalendarYearId,
(select Name from PYRLL_SYSTM_CalendarYear_Master
where PK_CalendarYear_Master_Id=@p_CalendarYearId and IsActive=1),
@p_HouseRentAmountFeb,@p_CreatedBy,
GETDATE(),GETUTCDATE(),0)
INSERT INTO PYRLL_TDS_Employee_HouseRentDetails
(FK_Employee_Id,FK_Calendar_Month_Id,FK_CalendarYear_Master_Id,Year,
HouseRentAmount,CreatedBy,CreatedOn,CreatedOnUTC,Disabled)
values --@p_CalendarMonthId
(@p_EmployeeId,3,@p_CalendarYearId,
(select Name from PYRLL_SYSTM_CalendarYear_Master
where PK_CalendarYear_Master_Id=@p_CalendarYearId and IsActive=1),
@p_HouseRentAmountMar,@p_CreatedBy,
GETDATE(),GETUTCDATE(),0)
INSERT INTO PYRLL_TDS_Employee_HouseRentDetails
(FK_Employee_Id,FK_Calendar_Month_Id,FK_CalendarYear_Master_Id,Year,
HouseRentAmount,CreatedBy,CreatedOn,CreatedOnUTC,Disabled)
values --@p_CalendarMonthId
(@p_EmployeeId,4,@p_CalendarYearId,
(select Name from PYRLL_SYSTM_CalendarYear_Master
where PK_CalendarYear_Master_Id=@p_CalendarYearId and IsActive=1),
@p_HouseRentAmountApr,@p_CreatedBy,
GETDATE(),GETUTCDATE(),0)
INSERT INTO PYRLL_TDS_Employee_HouseRentDetails
(FK_Employee_Id,FK_Calendar_Month_Id,FK_CalendarYear_Master_Id,Year,
HouseRentAmount,CreatedBy,CreatedOn,CreatedOnUTC,Disabled)
values --@p_CalendarMonthId
(@p_EmployeeId,5,@p_CalendarYearId,
(select Name from PYRLL_SYSTM_CalendarYear_Master
where PK_CalendarYear_Master_Id=@p_CalendarYearId and IsActive=1),
@p_HouseRentAmountMay,@p_CreatedBy,
GETDATE(),GETUTCDATE(),0)
End
End
only @p_HouseRentAmountJun
this value change
how to handle this case using Loop
@p_HouseRentAmountjan
@p_HouseRentAmountfeb
@p_HouseRentAmountmar
@p_HouseRentAmountapr
@p_HouseRentAmountMay
@p_HouseRentAmountJun
@p_HouseRentAmountJul
...
...
...
..
..
because insert 12 time uses
i am handle dis case one insert statement